The Code
We’ll program the ESP8266 using Arduino IDE, so you must have the ESP8266 add-on installed in your Arduino IDE.
Open your Arduino IDE and follow the step-by-step explanation of the code:
The first thing that you need to is to include all the libraries at the beginning:
2. Setup your network credentials:
3. Declare the GPIO pin that the DHT11 sensor is connected to. In our case we connected it to the GPIO 5 (D1).
Now you have to select the DHT type that you will be using. In our case we are using the DHT11.
Instantiate a DHTobject with the type and pin defined earlier.
Create an AsyncWebServerobject on port 80.
Create float variables to hold the current temperature and humidity values. The temperature and humidity are updated in the loop().
Create timer variables needed to update the temperature readings every 10 seconds.
Last updated