I am trying to use DHT11 with Blynk App. It was working perfectly fine 2 months ago. Today I am trying to use it again but no matter what I try, it just doesn’t work.
What I have already tried:
- Changing my sensor with a new one
- Updated Blynk libraries
- Trying different pins
Can anyone please help me to identify the problem?
[This is my exact circuit diagram](https://diygeeks.org/wp-content/uploads/2018/03/dht-iot.jpg)
Error Log:
[20718] Connecting to AndroidAP
[21221] Connected to WiFi
[21221] IP: 192.168.43.114
[21221]
___ __ __
/ _ )/ /_ _____ / /__
/ _ / / // / _ \/ '_/
/____/_/\_, /_//_/_/\_\
/___/ v0.5.4 on NodeMCU
[21302] Connecting to blynk-cloud.com:80
[31303] Connecting to blynk-cloud.com:80
[32040] Ready (ping: 180ms).
Failed to read from DHT sensor!
Failed to read from DHT sensor!
Failed to read from DHT sensor!
Code:
#define BLYNK_PRINT Serial // Comment this out to disable prints and save space
#include <SPI.h>
#include <ESP8266WiFi.h>
#include <BlynkSimpleEsp8266.h>
#include <SimpleTimer.h>
#include <DHT.h>
// You should get Auth Token in the Blynk App.
// Go to the Project Settings (nut icon).
char auth[] = "my_token"; //Enter the Auth code which was send by Blink
// Your WiFi credentials.
// Set password to "" for open networks.
char ssid[] = "AndroidAP"; //Enter your WIFI Name
char pass[] = "my_pass"; //Enter your WIFI Password
#define DHTPIN 0 // Digital pin D3
// Uncomment whatever type you're using!
#define DHTTYPE DHT11 // DHT 11
DHT dht(DHTPIN, DHTTYPE);
SimpleTimer timer;
void sendSensor()
{
float h = dht.readHumidity();
float t = dht.readTemperature(); // or dht.readTemperature(true) for Fahrenheit
if (isnan(h) || isnan(t)) {
Serial.println("Failed to read from DHT sensor!");
return;
}
// You can send any value at any time.
// Please don't send more that 10 values per second.
Blynk.virtualWrite(V5, h); //V5 is for Humidity
Blynk.virtualWrite(V6, t); //V6 is for Temperature
Blynk.virtualWrite(V7, h); // Humidity for graph
Blynk.virtualWrite(V8, t); // Temperature for
}
void setup()
{
Serial.begin(9600); // See the connection status in Serial Monitor
Blynk.begin(auth, ssid, pass);
dht.begin();
// Setup a function to be called every 5 second
timer.setInterval(5000L, sendSensor);
}
void loop()
{
Blynk.run(); // Initiates Blynk
timer.run(); // Initiates SimpleTimer
}
This is my settings and it was working previously. I also tried to change it to NodeMCU 1.0 (ESP 12E Module) but still not working.