This project demonstrates how to use an ESP32 to monitor temperature and humidity using a DHT22 sensor and display the data on a web interface. The ESP32 serves as a web server, providing real-time updates of sensor readings.
- Wi-Fi Connectivity: Connects to a Wi-Fi network to serve the web interface.
- DHT22 Sensor Integration: Reads temperature and humidity data from the DHT22 sensor.
- Web Interface: Displays real-time temperature and humidity data on a webpage.
- LED Control: Blinks an LED with a frequency based on the temperature reading.
- ESP32 board
- DHT22 sensor
- LED
- Resistors and wires for connections
WiFi.h: For Wi-Fi connectivity.AsyncTCP.h: For asynchronous TCP communication.ESPAsyncWebServer.h: For creating the web server.DHT.handAdafruit_Sensor.h: For interfacing with the DHT22 sensor.
- DHT Sensor Pin: Connected to GPIO 25.
- LED Pin: Connected to GPIO 2.
-
Install Libraries:
- Install the required libraries (
ESPAsyncWebServer,AsyncTCP,DHT) in your Arduino IDE.
- Install the required libraries (
-
Configure Wi-Fi:
- Replace
SSID_WIFIandWIFI_PASSWORDwith your Wi-Fi credentials in the code.
- Replace
-
Upload Code:
- Upload the provided code to your ESP32 using the Arduino IDE.
-
Connect Hardware:
- Connect the DHT22 sensor to GPIO 25 and the LED to GPIO 2.
-
Access Web Interface:
- After uploading the code, open the Serial Monitor to find the ESP32's IP address.
- Open a browser and navigate to the IP address to view the web interface.
- The ESP32 reads temperature and humidity data from the DHT22 sensor every 2 seconds.
- The data is served via a web interface, which updates every 2 seconds using JavaScript.
- The LED blinks with a frequency based on the temperature reading.
- Ensure the DHT22 sensor is properly connected and powered.
- The LED blinking frequency is mapped to the temperature range (15°C to 40°C).
This project is MIT.