0% found this document useful (0 votes)
81 views

DHT11SENSOR With Blynk App

Uploaded by

shree
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
81 views

DHT11SENSOR With Blynk App

Uploaded by

shree
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 11

Interfacing DHT Sensor with ESP32 Using Arduino IDE

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:

 ESP32 development board


 DHT 11 Temperature & Humidity Sensor
 USB cable
 Breadboard and Jumper wire
 Power Source and Computer with Arduino IDE
 Blynk app installed on your smartphone

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:

 Replace your_SSID, your_PASSWORD, and your_AUTH_TOKEN with your Wi-Fi


credentials and Blynk authentication token, respectively.
 Adjust the DHTPIN to match the GPIO pin you've connected the DHT sensor to.

UPLOAD THE CODE:


 Select the correct board and port in the Arduino IDE.
 Upload the code to your ESP32.

RUN THE BLYNK APP:


 Open the Blynk app, load the project you created.
 Press the "Play" button to start the project.
Now, the Blynk app should display the temperature and humidity values from the DHT sensor
connected to your ESP32. Adjust the virtual pin numbers in the code to match those used in your
Blynk app project.
PROGRAM:

DHT DATA READING AND TRANSFER TO BYLNK

#define BLYNK_TEMPLATE_ID "TMPL3w2H97lco"


#define BLYNK_TEMPLATE_NAME "Temperature monitor"
#define BLYNK_AUTH_TOKEN "axG-Isjy-lZVdEB1BetYQLpRdDW6mOVb"
#include <WiFi.h>
#include <BlynkSimpleEsp32.h>
#include <DHT.h>

#define DHTPIN 22 // Pin where the DHT11 is connected


#define DHTTYPE DHT11 // DHT 11

char auth[] = "axG-Isjy-lZVdEB1BetYQLpRdDW6mOVb"; // You'll receive this


after creating a Blynk project
char ssid[] = "TANSAM";
char pass[] = "Tansam@123";

DHT dht(DHTPIN, DHTTYPE);


BlynkTimer timer;

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

Now click the device tab and New Device

Select the form template


Click the create button

OUTPUT:

EXPERIMENTAL SETUP

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy