DHT11SENSOR With Blynk App
DHT11SENSOR With Blynk App
Interfacing a DHT sensor with the ESP32 using the Arduino IDE for IoT applications
involves connecting the sensor to the ESP32 microcontroller, typically via digital pins, and
programming it to read temperature and humidity data.
Implementing a DHT sensor with an ESP32 and controlling it through the Blynk app involves
several steps. Below is a basic guide to help you get started. This assumes you have the Arduino IDE
installed and set up for ESP32 development.
HARDWARE REQUIRED:
SOFTWARE REQUIRED:
Arduino IDE
Blynk Library for Arduino
STEPS INVOLVED :
1. Install Libraries:
Open the Arduino IDE, go to "Sketch" > "Include Library" > "Manage Libraries." Search for
and install the following libraries:
void sendSensorData()
{
float temperature = dht.readTemperature();
float humidity = dht.readHumidity();
if (isnan(temperature) || isnan(humidity))
{
Serial.println("Failed to read from DHT sensor!");
return;
}
Serial.print("Temperature(°C):");
Serial.println(temperature);
Serial.print("Humidity:");
Serial.println(humidity);
Blynk.virtualWrite(V0, temperature); // Virtual Pin V1 for temperature
Blynk.virtualWrite(V1, humidity); // Virtual Pin V2 for humidity
if(temperature < 30) {
Blynk.logEvent("alert","Warning");
}
}
void setup()
{
Serial.begin(115200);
Blynk.begin(auth, ssid, pass);
dht.begin();
timer.setInterval(5000L, sendSensorData); // Send sensor data every 5
seconds
}
void loop()
{
Blynk.run();
timer.run();
}
EXPERIMENTAL SETUP:
Click the setting icon and the scree will be displayed as follows
Click the save button
OUTPUT:
EXPERIMENTAL SETUP