DHT11 Interfacing with NodeMcu & Blynk 2.0 | New Blynk 2.0 Project | Temperature & Humidity

Temperature and humidity monitoring

Circuit Diagram:

dht11 blynk p-l

Code:

#define BLYNK_TEMPLATE_ID "******************"
#define BLYNK_TEMPLATE_NAME "******************"
#define BLYNK_AUTH_TOKEN "******************"

#define BLYNK_PRINT Serial

#include <ESP8266WiFi.h>
#include <BlynkSimpleEsp8266.h>
#include <DHT.h>

#define DHTPIN 14 // DHT11 sensor pin D5

#define DHTTYPE DHT11 // DHT11 sensor type
DHT dht(DHTPIN, DHTTYPE);

char auth[] = BLYNK_AUTH_TOKEN;
char ssid[] = "*******"; // Your hotspot name
char pass[] = "*******"; // Your hotspot password

void setup()
{
 Serial.begin(9600);
 dht.begin();
 Blynk.begin(auth, ssid, pass);
}

void loop()
{
 Blynk.run();
 float temp = dht.readTemperature();
 float hum = dht.readHumidity();
 if (isnan(temp) || isnan(hum)) {
 Serial.println("Failed to read from DHT sensor!");
 return;
 }

Blynk.virtualWrite(V1, temp);
 Blynk.virtualWrite(V2, hum);
 delay(2000);
}