DHT11 Instable Value

Hello everyone,
I’m new in the community and I am just approaching the IoT world, and I’m doing it with Blynk.
I need to display the values ​​of a temperature sensor DHT11 and command at the same time a relay. I used a Wemos D1 R2, a DHT11 (with a 4.7k resistor between pin 1 and pin 2) and small relay. I created my first sketch, taking various bits here and there, and it came out the following:

define BLYNK_PRINT Serial
include ESP8266WiFi.h
include BlynkSimpleEsp8266.h
include SimpleTimer.h
include dht11.h
dht11 DHT;
define DHT11_PIN 14
// You should get Auth Token in the Blynk App.
// Go to the Project Settings (nut icon).
char auth = “c522c8390f064cc897a430424b822bd8”; //insert here your token generated by Blynk
// Your WiFi credentials.
// Set password to “” for open networks.
char ssid = “Vodafone-33990400”;
char pass = “tjm4bkdds3vdvx5”;

SimpleTimer timer;

void setup()
{
Serial.begin(9600); // See the connection status in Serial Monitor
Blynk.begin(auth, ssid, pass);

// Setup a function to be called every second
timer.setInterval(1000L, sendUptime);
}

// 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 sendUptime()
{
// You can send any value at any time.
// Please don’t send more that 10 values per second.
Blynk.virtualWrite(10, DHT.temperature); //virtual pin
Blynk.virtualWrite(11, DHT.humidity); // virtual pin
}

void loop()
{
Blynk.run(); // Initiates Blynk
timer.run(); // Initiates SimpleTimer
int chk;
chk = DHT.read(DHT11_PIN); // READ DATA

Serial.print("Umidita'    (%): ");

Serial.println(DHT.humidity, DEC);

Serial.print("Temperatura (C): “);
Serial.println(DHT.temperature, DEC);
Serial.println(” ");
}

The problem is that the values ​​of DHT11 are displayed, for some short time properly, then stabilize to 11 ° C and 145 to the humidity. Occasionally I show again the values ​​it gives me to a place still reading instability.
How can I do?

Firstly, format your code correctly.

```cpp
CODE
```

Then we can help you.

…and secondly, increase the read time interval! Unless you are boiling eggs’ you don’t need to read temperature every second (try with 5secs, for example, or even 1 minute)

@francescobiancardi : are you running a free hotspot?? :wink:

1 Like