Comments on: Complete Guide for DHT11/DHT22 Humidity and Temperature Sensor With Arduino https://randomnerdtutorials.com/complete-guide-for-dht11dht22-humidity-and-temperature-sensor-with-arduino/ Learn ESP8266, ESP32, Arduino, and Raspberry Pi Mon, 28 Mar 2022 17:33:50 +0000 hourly 1 https://wordpress.org/?v=6.8.2 By: Boris Levitan https://randomnerdtutorials.com/complete-guide-for-dht11dht22-humidity-and-temperature-sensor-with-arduino/#comment-734356 Mon, 28 Mar 2022 17:33:50 +0000 http://randomnerdtutorials.com/?p=5378#comment-734356 The problem I’ve get was an unstable operation. The sketch loop block internally interrupted and operation started with printing DHTxx test! . That happened sporadically more or less frequently, sometimes normal reading doesn’t working, just a few lines printing with DHTxx test!.
In my case the problem solved with adding small delays between sensor reading statements:
void loop() {
// Wait a few seconds between measurements.
delay(2000);

// Reading temperature or humidity takes about 250 milliseconds!
// Sensor readings may also be up to 2 seconds ‘old’ (its a very slow sensor)
Serial.print(F(“Start to read: “));
float h = dht.readHumidity(); Serial.print(F(” h, “));
delay(250); // making readings form the sensor more sparce
// Read temperature as Celsius (the default)
float t = dht.readTemperature(); Serial.print(F(” t, “));
delay(250); // making readings form the sensor more sparce
// Read temperature as Fahrenheit (isFahrenheit = true)
float f = dht.readTemperature(true); Serial.print(F(” f “));
delay(250); // making readings form the sensor more sparce
// Check if any reads failed and exit early (to try again).
if (isnan(h) || isnan(t) || isnan(f)) {
Serial.println(F(“Failed to read from DHT sensor!”));
return;
}
//}

// Compute heat index in Fahrenheit (the default)
float hif = dht.computeHeatIndex(f, h); Serial.print(F(” Calculate hiV “));
// Compute heat index in Celsius (isFahreheit = false)
float hic = dht.computeHeatIndex(t, h, false); Serial.print(F(” Calculate hiC “));
delay(1000); Serial.println(F(” Ready to print “));
//Serial.println(F(“all are ready”));
Serial.print(F(“Humidity: “));
Serial.print(h);
Serial.print(F(“% Temperature: “));
Serial.print(t);
Serial.print(F(“°C “));
Serial.print(f);
Serial.print(F(“°F Heat index: “));
Serial.print(hic);
Serial.print(F(“°C “));
Serial.print(hif);
Serial.println(F(“°F”));
}

One more unstable issue is delay() method operation. From time to time it starts to work with falce delay interval much less than requested by parameter of the method. Usually it turns into normal opreation after a few minutes ubnormality.

]]>
By: vilasrao https://randomnerdtutorials.com/complete-guide-for-dht11dht22-humidity-and-temperature-sensor-with-arduino/#comment-427587 Sat, 08 Feb 2020 09:42:41 +0000 http://randomnerdtutorials.com/?p=5378#comment-427587 Well ! Best tutorial !

]]>
By: Sara Santos https://randomnerdtutorials.com/complete-guide-for-dht11dht22-humidity-and-temperature-sensor-with-arduino/#comment-363685 Sat, 27 Apr 2019 10:08:43 +0000 http://randomnerdtutorials.com/?p=5378#comment-363685 In reply to yuvraj agarwal.

Hi.
We have this tutorial that may help. https://randomnerdtutorials.com/arduino-temperature-displayed-on-4-digit-7-segment/
Please note that this tutorial is a few years old. I’m not sure if it is still working.
Regards,
Sara

]]>
By: yuvraj agarwal https://randomnerdtutorials.com/complete-guide-for-dht11dht22-humidity-and-temperature-sensor-with-arduino/#comment-363664 Sat, 27 Apr 2019 05:58:13 +0000 http://randomnerdtutorials.com/?p=5378#comment-363664 How do i show the temperature on a 3 digit seven segment display?PLEASE!?

]]>
By: Sara Santos https://randomnerdtutorials.com/complete-guide-for-dht11dht22-humidity-and-temperature-sensor-with-arduino/#comment-357029 Sun, 03 Mar 2019 17:48:38 +0000 http://randomnerdtutorials.com/?p=5378#comment-357029 In reply to Al.

Hi Al.
Please check that the sensor is being properly powered (5V to the Vin pin of the sensor).
Regards,
Sara

]]>
By: Al https://randomnerdtutorials.com/complete-guide-for-dht11dht22-humidity-and-temperature-sensor-with-arduino/#comment-356930 Sat, 02 Mar 2019 22:33:41 +0000 http://randomnerdtutorials.com/?p=5378#comment-356930 I have tried this method and several other libraries. I hoping this would be the one that worked. But still no go. I can hook up the DHT22 to my Arduino UNO and it reads Temp/Humidity just fine, but I cannot get the ESP8266-01 to read data. I get the “Failed to read from DHT sensor.” Any thoughts on why it works on the UNO but not on the EP8266? Thank you!

]]>
By: Sara Santos https://randomnerdtutorials.com/complete-guide-for-dht11dht22-humidity-and-temperature-sensor-with-arduino/#comment-337436 Thu, 04 Oct 2018 15:47:48 +0000 http://randomnerdtutorials.com/?p=5378#comment-337436 In reply to zikry.

Hi.
Yes! Here’s the tutorial:
https://randomnerdtutorials.com/esp32-dht11-dht22-temperature-humidity-web-server-arduino-ide/
Regards,
Sara 🙂

]]>
By: zikry https://randomnerdtutorials.com/complete-guide-for-dht11dht22-humidity-and-temperature-sensor-with-arduino/#comment-337264 Wed, 03 Oct 2018 13:40:17 +0000 http://randomnerdtutorials.com/?p=5378#comment-337264 do you have any tutorial on how to connect to esp32 with DHT11, because i’m really new to this. I really need your help

]]>
By: Sara Santos https://randomnerdtutorials.com/complete-guide-for-dht11dht22-humidity-and-temperature-sensor-with-arduino/#comment-332915 Fri, 31 Aug 2018 08:58:31 +0000 http://randomnerdtutorials.com/?p=5378#comment-332915 In reply to Ralph Hulslander.

Hi.
You can use an ethernet shield connected to the Arduino.
Or you may consider using an ESP8266 or an ESP32. Take a look at the following tutorials that might help you:
https://randomnerdtutorials.com/esp8266-dht11dht22-temperature-and-humidity-web-server-with-arduino-ide/
https://randomnerdtutorials.com/esp32-dht11-dht22-temperature-humidity-web-server-arduino-ide/
I hope this helps.
Regards,
Sara 🙂

]]>
By: Sara Santos https://randomnerdtutorials.com/complete-guide-for-dht11dht22-humidity-and-temperature-sensor-with-arduino/#comment-332914 Fri, 31 Aug 2018 08:52:03 +0000 http://randomnerdtutorials.com/?p=5378#comment-332914 In reply to Kara.

Hi Kara.
It seems that you also need to install the Adafruit_Sensor library.
Here’s the link for that library:
https://github.com/adafruit/Adafruit_Sensor
I hope this helps.
Regards,
Sara 🙂

]]>