Add details :
• Hardware model + communication type. For example: Arduino UNO with Ethernet Shield
• Smartphone OS (iOS or Android) + version
• Blynk server or local server
• Blynk Library version
• Add your sketch code. Code should be formatted as example below.
Simply paste your code between ``` If you don’t format your code, your topic can be deleted by moderators.
Dear Pete,
I tried with the example you suggested, and this is the error message!
Arduino: 1.8.7 (Windows 7), Board: "NodeMCU 1.0 (ESP-12E Module), 80 MHz, Flash, Legacy (new can return nullptr), All SSL ciphers (most compatible), 4MB (FS:2MB OTA:~1019KB), 2, v2 Lower Memory, Disabled, None, Only Sketch, 115200"
Build options changed, rebuilding all
Multiple libraries were found for "BlynkSimpleEsp8266.h"
In file included from C:\Users\Pvinnailevi\Documents\Arduino\libraries\DHT_sensor_library\DHT_U.cpp:15:0:
Used: C:\Users\Pvinnailevi\Documents\Arduino\libraries\Blynk_For_Chinese
Not used: C:\Users\Pvinnailevi\Documents\Arduino\libraries\Blynk
Not used: C:\Users\Pvinnailevi\Documents\Arduino\libraries\Blynk
Not used: C:\Users\Pvinnailevi\Documents\Arduino\libraries\Blynk
Not used: C:\Users\Pvinnailevi\Documents\Arduino\libraries\Blynk
Multiple libraries were found for "DHT.h"
Used: C:\Users\Pvinnailevi\Documents\Arduino\libraries\DHT_sensor_library
Not used: C:\Users\Pvinnailevi\Documents\Arduino\libraries\Grove_Temperature_And_Humidity_Sensor
C:\Users\Pvinnailevi\Documents\Arduino\libraries\DHT_sensor_library\DHT_U.h:36:29: fatal error: Adafruit_Sensor.h: No such file or directory
#include <Adafruit_Sensor.h>
^
compilation terminated.
exit status 1
Error compiling for board NodeMCU 1.0 (ESP-12E Module).
This report would have more information with
"Show verbose output during compilation"
option enabled in File -> Preferences.
If you’d have read the comments at the beginning of the code example that you downloaded, you would have seen this:
*************************************************************
This example shows how value can be pushed from Arduino to
the Blynk App.
WARNING :
For this example you'll need Adafruit DHT sensor libraries:
https://github.com/adafruit/Adafruit_Sensor
https://github.com/adafruit/DHT-sensor-library
App project setup:
Value Display widget attached to V5
Value Display widget attached to V6
*************************************************************/
You obviously haven’t followed the instruction to download and install the Adafruit libraries, which is why the compiler is saying:
Dear Pete, I found a mistake! Works fine with nodemcu in blynk on dht11! But! If the connection between nodemcu and dht11 is disconnected, or between the network and nodemcu, the gauge will still display a real value in the blynk! It would be nice if the connection is lost somewhere then just write dots instead of gauge values! Is it possible? Thank you.
Adding these two new lines of code should fix the problem if the sensor is disconnected, although I’ve not tried it…
if (isnan(h) || isnan(t)) {
Serial.println("Failed to read from DHT sensor!");
// new lines added by Pete Knight...
Blynk.virtualWrite(V5, "- - -");
Blynk.virtualWrite(V6, "- - -");
return;
}
As far as solving the problem of a value still showing when the device Is disconnected from the Blynk server, that can’t be done, but you will get a red dot at the top of the app screen to show that your device is offline, so you’ll know that the readings displayed are incorrect.
Hi Pete, Tried it but unfortunately it doesn’t work! By inserting the 2 lines you will no longer allow it to be uploaded to nodemcu! Could I have copied the two lines incorrectly?
It looks like the forum has changed the quotation marks from normal ones to ones that slope to the right.
This would give a message something like “stray character 222” when you compile it.
Edit the sketch and the-type the quotation marks and it should work.
I am facing the same problem with the same codes for DHT11… but i did not get this message, like what are the steps exactly to make it work without disconnecting or offline.
The blynk application on the top of the app screen it shows that your device is offline then disconnected
#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[] = "QxVfsb-qOWXonSGHW79mOUGoY6i8Gtnw";
// Your WiFi credentials.
// Set password to "" for open networks.
char ssid[] = "Glide";
char pass[] = "";
#define DHTPIN 2 // D3
// 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!");
// You can send any value at any time.
// Please don't send more that 10 values per second.
Blynk.virtualWrite(V5, "t = dht.readTemperature()");
Blynk.virtualWrite(V6, "h = dht.readHumidity()");
return;
}
}
void setup()
{
// Debug console
Serial.begin(9600);
Blynk.begin(auth, ssid, pass,"blynk-cloud.com", 8442);
// 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(1000L, sendSensor);
}
void loop()
{
Blynk.run();
timer.run();
}