Fire up the ESP32
Emulating web things is boring. Espressif’s ESP32 lets us build something real Espressif does not offer its core libraries via the Arduino deployment system – instead, code must be downloaded using Github via the command git clone https://github.com/me-no-dev/ espasyncwebserver. Compress the contents of the received repository to create a file called Espasyncwebserver.zip, and install it using the Manage Libraries option of the Arduino IDE. Repeat the process with the second library, which resides at https://github.com/me-no-dev/ asynctcp. A full archive can also be found at http://www. tamoggemon.com/test/2018/ esp32-webthings-libs.zip. Finally, click Sketch → Include Library → Manage Libraries, look for “Arduinojson” and select version 5.13.2 for installation – beta versions of V6 are not supported. The final missing library is called webthing, as of this writing, version 0.4.1 is current.
CREATE A SKETCH
Our program starts off by including a set of headers providing access to the hardware. We connect an LED to GPIO 12 in order to let our thing emit information to the outside world. Things expose a set of properties. In the case of the Arduino library, create a few global variables to hold status and other information: The bulk of the code is responsible for the establishment of a Wifi connection. Be sure to replace ssid and password with values applicable to your local network. Once the Wifi stack is connected to a network, information about the IP address can be emitted to the serial monitor of the IDE: The last part of the program provides CPU time to the adapter during invocations of the loop() function: When done, install the program on your ESP32 and note down the URL emitted in the serial monitor – in the following steps, we assume http://192.168.1.105/things/led