This project demonstrates how to use the DHT11 sensor with Blynk to monitor temperature and humidity. The ESP32 reads data from the DHT11 sensor and sends it to the Blynk app for real-time monitoring.
- DHT11 Sensor: Measures temperature and humidity.
- ESP32: Microcontroller to read sensor data and connect to Blynk.
- Breadboard and Jumper Wires: For circuit connections.
- Blynk App: For real-time monitoring on your smartphone.
- Arduino IDE: For writing and uploading code to ESP32.
- Temperature Monitoring: Real-time temperature data from DHT11.
- Humidity Monitoring: Real-time humidity data from DHT11.
- Blynk Integration: Data visualization and monitoring on the Blynk app.
- Connect the DHT11 sensor to the ESP32:
- VCC to 3.3V or 5V
- GND to GND
- Data to a digital pin (e.g., GPIO 4)
- Install the Arduino IDE from Arduino.
- Install the Blynk library:
- Open Arduino IDE
- Go to
Sketch
>Include Library
>Manage Libraries
- Search for "Blynk" and install it
- Install the DHT sensor library:
- Open Arduino IDE
- Go to
Sketch
>Include Library
>Manage Libraries
- Search for "DHT sensor library" and install it
- Download the Blynk app from the App Store or Google Play Store.
- Create a new project and note the Auth Token sent to your email.
- Add two Gauge widgets in the Blynk app for temperature and humidity.
- Set the pin for temperature to V1 and humidity to V2.
-
Open Arduino IDE and create a new sketch.
-
Copy and paste the following code:
#define BLYNK_PRINT Serial #include <WiFi.h> #include <BlynkSimpleEsp32.h> #include <DHT.h> // Replace with your Blynk Auth Token char auth[] = "YourAuthToken"; // Replace with your WiFi credentials char ssid[] = "YourNetworkName"; char pass[] = "YourPassword"; #define DHTPIN 4 // Digital pin connected to the DHT sensor #define DHTTYPE DHT11 // DHT 11 DHT dht(DHTPIN, DHTTYPE); BlynkTimer timer; void sendSensorData() { float h = dht.readHumidity(); float t = dht.readTemperature(); if (isnan(h) || isnan(t)) { Serial.println("Failed to read from DHT sensor!"); return; } Blynk.virtualWrite(V1, t); Blynk.virtualWrite(V2, h); } void setup() { Serial.begin(115200); Blynk.begin(auth, ssid, pass); dht.begin(); timer.setInterval(2000L, sendSensorData); } void loop() { Blynk.run(); timer.run(); }
-
Replace
YourAuthToken
,YourNetworkName
, andYourPassword
with your Blynk Auth Token and WiFi credentials. -
Upload the code to your ESP32.
- Power your ESP32.
- Open the Blynk app to monitor temperature and humidity in real-time.
Contributions are welcome! Please fork the repository and create a pull request with your changes.
This project is licensed under the MIT License.