klips/esp/cpp/03_temp-humidity-web

03_temp-humidity-web

This example is largely adapted from those in ESP32-basic-starter-kit.pdf.

The APIs in the original examples paired with this PDF have changed, and I decided to do some different things with the code and/or circuits, but the original code can be found here.

schematic

Temperature and humidity sensor served on a web page within the local network.

screenshot

Dependencies

You need to install a couple of libraries for this project:

  • The DHT and the Adafruit Unified Sensor Driver libraries to read from the DHT sensor.
  • ESPAsyncWebServer and Async TCP libraries to build the asynchronous web server.

The default Arduino IDE installation will store libraries at ~/Arduino/ibraries - if this directory doesn't exist, create it.

Installing DHT Sensor Library

To read from the DHT sensor using Arduino IDE, you need to install the DHT sensor library.

wget -O DHT_sensor.zip https://github.com/adafruit/DHT-sensor-library/archive/master.zip
unzip DHT_sensor.zip
mv DHT-sensor-library-master/ ~/Arduino/libraries/DHT_sensor

Install Adafruit Unified Sensor Driver Library

You also need to install the Adafruit Unified Sensor Driver library to work with the DHT sensor.

wget -O Adafruit_sensor.zip https://github.com/adafruit/Adafruit_Sensor/archive/master.zip
unzip Adafruit_sensor.zip
mv Adafruit_Sensor-master/ ~/Arduino/libraries/Adafruit_sensor

Installing ESPAsyncWebServer Library

Follow the next steps to install the ESPAsyncWebServer library:

wget -O ESPAsyncWebServer.zip https://github.com/me-no-dev/ESPAsyncWebServer/archive/master.zip
unzip ESPAsyncWebServer.zip
mv ESPAsyncWebServer-master/ ~/Arduino/libraries/ESPAsyncWebServer

Installing Async TCP Library

The ESPAsyncWebServer library requires the AsyncTCP library to work. Follow the next steps to install that library:

wget -O AsyncTCP.zip https://github.com/me-no-dev/AsyncTCP/archive/master.zip
unzip AsyncTCP.zip
mv AsyncTCP-master/ ~/Arduino/libraries/AsyncTCP