Problem Statement:
I am using Blynk Example Browser to build DHT11 sketch, I can see temperture & humidity in serial window successfuly, but did not see any value show up in Blynk Labled Value Display Widgets, both temperature & humidity labels showed " %.3f ", I was doing DHT22/NodeMcu with Blynk Widgets several times without any issue, but I could not figure out what is going on for this case, can somebody show me which portion could be wrong, thank you.
- Hardware model: NodeMcu ESP8266 with Wi-Fi
- Using Android 6.0.1 with latest Blynk App
- Using Blynk Server
- Using Blynk Library version: v0.5.3
- Using Updated DHT library 1.3.0
Log 1:
[4235] Connected to WiFi
[4236]
___ __ __
/ _ )/ /_ _____ / /__
/ _ / / // / _ / '/
///_, /////_
/__/ v0.5.3 on NodeMCU
Give Blynk a Github star! => https://github.com/blynkkk/blynk-library
[4248] Connecting to blynk-cloud.com:80
[4558] Ready (ping: 0ms).
Temperature: 30.00C
Humidity: 58.00%
Temperature: 28.00C
Humidity: 54.00%
#define BLYNK_PRINT Serial
#include <ESP8266WiFi.h>
#include <BlynkSimpleEsp8266.h>
#include <DHT.h>
// You should get Auth Token in the Blynk App.
// Go to the Project Settings (nut icon).
char auth[] = "";
// Your WiFi credentials.
// Set password to "" for open networks.
char ssid[] = "";
char pass[] = "";
#define DHTPIN 2 // What digital pin we're connected to
// Uncomment whatever type you're using!
#define DHTTYPE DHT11 // DHT 11
//#define DHTTYPE DHT22 // DHT 22, AM2302, AM2321
//#define DHTTYPE DHT21 // DHT 21, AM2301
DHT dht(DHTPIN, DHTTYPE);
BlynkTimer timer;
// This function sends Arduino's up time every second to Virtual Pin (5).
// In the app, Widget's reading frequency should be set to PUSH. This means
// that you define how often to send data to Blynk App.
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(V99, h);
Blynk.virtualWrite(V100, t);
Serial.print("Temperature: ");
Serial.print(t);
Serial.println("*C\t");
Serial.print("Humidity: ");
Serial.print(h);
Serial.println("%\t");
}
void setup()
{
// Debug console
Serial.begin(115200);
Blynk.begin(auth, ssid, pass);
// You can also specify server:
//Blynk.begin(auth, ssid, pass, "blynk-cloud.com", 8442);
//Blynk.begin(auth, ssid, pass, IPAddress(192,168,1,100), 8442);
dht.begin();
// Setup a function to be called every second
timer.setInterval(15000L, sendSensor);
}
void loop()
{
Blynk.run();
timer.run();
}