This project uses ESP8266 NODEMCU module and the DHT11 temperature and humidity sensor with Arduino IDE to send the temperature and humidity readings to the adafruit Iot platform using MQTT protocol.
We are using wifi manager library by tzapu to manage the changes in the WiFi settings (SSID and Password), So thanks to tzapu. To install wifi manager library.
We are using DHTesp library file by “beegee Tokyo” to read the temperature and humidity easily from DHT11 sensor, thanks to beegee Tokyo. To install DHTesp library.
We are using andruino json library by Benoît Blanchon to create and read the configration file in the SPIFFS, Benoît Blanchon thank you. To install ArduinoJson library.
Last external library we use in this project is the adafruit MQTT library by Adafruit, big thanks to Adafruit. To Install the adafruit MQTT library for Arduino.
The ESP8266 reads the temperature and the humidity through the DHT11 sensor. It connects to the Adafruit IO website through WiFi and sends the sensor readings to the feeds through MQTT. We have setup a Webserver on the ESP8266 to configure the Adafruit IO logging parameters:
- Start/Stop sending the data.
- The frequency of sending.
- Adafruit IO API key.
All this is done through the “control settings” HTML page that’s hosted in ESP8266 web server.
To run the code you need to:
- Install the wifi manager library from github. or from the tools menu in the Arduino IDE. choose “Manage libraries”, then type wifimanager in the search bar and install the one from tzapu. I used version 0.14.0.
- Install the DHTesp library from github, or from the library Manager, type DHTesp in the search bar and install it. I used version 1.0.9.
- Install the ArduinoJson library from github, Or in Manage libraries type ArduinoJson in the search bar and install it.
- Install the adafruit MQTT library from github or from the tools menu in the Arduino IDE. choose “Manage libraries” , and type adafruit MQTT library in the search bar and install it.
- Upload the HTML files in the data folder to the SPIFFS by clicking “ESP8266 sketch data upload” from the tools menu of the Arduino IDE, be sure that the serial window is closed. If you do not have the “ESP8266 sketch data upload” in the tools menu please check this link to install the plugin. This will add the control settings page to the ESP8266 web server.
For more details please check our blog post