• Skip to main content
  • Skip to primary sidebar

RNTLab.com

The Ultimate Shortcut to Learn Electronics and Programming with Open Source Hardware and Software

  • Courses
  • Forum
    • Forum
    • Ask Question
  • Shop
  • Account
  • Blog
  • Login

My dht22 does not give readings on the ESP32. Seems the timing is off. It works correctly on UNO. What is the solution for this?

Q&A Forum › My dht22 does not give readings on the ESP32. Seems the timing is off. It works correctly on UNO. What is the solution for this?
0 Vote Up Vote Down
James asked 6 years ago
21 Answers
0 Vote Up Vote Down
Rui Santos Staff answered 6 years ago

Hi James! How are you powering the DHT22 with 5V or 3.3V? What’s the error message that you see in the Arduino IDE Serial monitor?

0 Vote Up Vote Down
James answered 6 years ago

The set up is exactly like you show in your course. I’m basically getting ‘Nan’ though your scratch prints ‘failed’. I used a different DHT library without failed readings.

0 Vote Up Vote Down
Rui Santos Staff answered 6 years ago

But can you double-check and let me know. How are you powering the DHT22 with 5V or 3.3V?
Thanks for your patience,
Rui

0 Vote Up Vote Down
James answered 6 years ago

The DHT22 is connected to the 3.3v pin of the ESP32.

0 Vote Up Vote Down
Rui Santos Staff answered 6 years ago

Hum… Can you try to power it with 5V (with the Vin pin)? How are you powering your ESP32 board with a USB port from your computer?

0 Vote Up Vote Down
mikces1 answered 6 years ago

Hello
I have such problem too. My ESP32  and AM2302 don’t work with DHT.h .The sensor  work well  with Arduino board.
I try the ESP32 and AM2302 with libraries DHTesp.h and Ticker.h (exaples from github.com). Examle work well. I think, that it is need to correct time intervals in library DHT.h.
I am sorry, my English is imperfect.
Ceslavas

0 Vote Up Vote Down
Rui Santos Staff answered 6 years ago

Hello Ceslavas. Can you try to power it with 5V (with the Vin pin)?
How are you powering your ESP32 board with a USB port from your computer?

0 Vote Up Vote Down
mikces1 answered 6 years ago

Yes, I do. I try  power sensor with 3,3 in first, then from 5V. The answer was “Nan” both times.  I am powering ESP32 with USB port from computer.
The examples with libraries “DHTesp.h”  and “Tickers.h”  I try with 5V only  .

0 Vote Up Vote Down
Rui Santos Staff answered 6 years ago

Did those examples work with your ESP “DHTesp.h”?
Can you try to power your ESP32 with an external power source or with like a phone charger to see if it’s a power problem. 
Thanks!

0 Vote Up Vote Down
mikces1 answered 6 years ago

I don’t understand what happened. ESP32  and  AM2302 begin work with DHT.h when I  trying it again today. I wantetd to load a program at first so I powered ESP32 with USB port from computer. Program with DHT.h begin work well ! I did not renew the schemes. Many times I loaded the programs with DHT.h and DHTesp.h a few days ago. ESP32 and AM2302 don’t worked with DHT.h. I wonder how it will be tomorrow?
Forgive me for unnecessary disturbance.

0 Vote Up Vote Down
Rui Santos Staff answered 6 years ago

Hello, so is it working now? The DHT can crash due to poor wiring (unstable cables that might get disconnected) or insufficient power…

0 Vote Up Vote Down
esp8266 answered 6 years ago

Hello,
I have the same problem. The DHT22 works well with Arduino UNO.
With ESP32 not.
I tested it with 3.3V, 5V from ESP32 and I tested it with 5V external power for the DHT22.
I tested also the pin 14 with the code pushbutton_led.py, the pin works.
Also tested with the ESP8266 it works well with 3.3V internal power.
Regards
Franz
 

0 Vote Up Vote Down
Rui Santos Staff answered 6 years ago

Hello Franz, I need a few more details:

  • How are you powering your ESP Franz? How much amperage did the external power supply provided?
  • Can you add a 10uF to 22uF electrolytic capacitor to your Vin and GND pins?

Does that work for you? Thanks!

0 Vote Up Vote Down
esp8266 answered 6 years ago

Hello Rui,
the powersupply provides 2000mA / 5V, connected to the micro USB.
I tested  it with 3.3V and 5V for the DHT22 and with 10µF and 20µF.
No succes. I get always “Failed to read sensor”. Again: with EPS8266 it works.
Regards
Franz

0 Vote Up Vote Down
esp8266 answered 6 years ago

Heureca!
I tested the same configuration with the scetch from:

ESP32 DHT11/DHT22 Web Server – Temperature and Humidity using Arduino IDE


It works fine
 

0 Vote Up Vote Down
esp8266 answered 6 years ago

And it works with 3.3V and 5V connected with USB – PC and without capacitors and no additional powersupply. Power consumption is 0.138A

0 Vote Up Vote Down
Rui Santos Staff answered 6 years ago

So, what wasn’t working before? Which code where you running?

0 Vote Up Vote Down
esp8266 answered 6 years ago

Summary:
I tested the DHT22 with ESP32 and ESP8266-12E and I tested it with microPython-Code from the course and the Arduino IDE with Your code three posts before.
Also I tested it with different power (3.3V and 5V) and with added capacitors.
The ESP32 and DHT22 don’t works with microPython!!
But it works with Arduino IDE.
And it works with ESP8266 microPython and Arduino IDE
And now:
Suddenly I can’t flash the ESP32 with MicroPython anymore. But with the Arduino IDE I can program the ESP32.
The serialmonitor gives a read error on 0x1000.
I’m sorry
regards Franz
 

0 Vote Up Vote Down
Rui Santos Staff answered 6 years ago

Hello Franz, there seems to be multiple problems that you’re having and to be honest I can’t replicate those on my end. When the DHT11/DHT22 failed to read from DHT sensor doesn’t work, it’s usually:

  • Power issue
  • Wrong wiring
  • Faulty DHT
  • Faulty ESP8266

Please read our DHT11/DHT22 Troubleshooting Guide.

I’ve re-tested the code on my ESP (both with Arduino IDE and MicroPython) and it works for me. Once in a while, one of the reading fails, but after that it starts reading again.

The problems that you’re facing are an unknown reason for me and I would have to personally test your circuit. Based on that information I don’t know what it can be…

The “The serialmonitor gives a read error on 0x1000.” seems like you didn’t flash the MicroPython firmware to the ESP32 in the right address.

The MicroPython firmware for the ESP32 must be flashed in that address (0x1000).

Thank you for your patience throughout this process. Regards,

Rui

0 Vote Up Vote Down
esp8266 answered 6 years ago

Hello Rui,
Thank you for your!!! patience.
It seems, I found the solution. I bought a new breadboard.
Now it works.
Thanks again
 

0 Vote Up Vote Down
Rui Santos Staff answered 6 years ago

I’m glad it’s working now! It was probably some wiring issue. I’ll mark this thread as resolved, if you have more questions feel free to post them here: https://rntlab.com/ask-question/

Primary Sidebar

Login to Ask or Answer Questions

This Forum is private and it’s only available for members enrolled in our Courses.

Login »

Latest Course Updates

  • [New Edition] Build ESP32-CAM Projects eBook – 2nd Edition April 16, 2025
  • [eBook Updated] Learn ESP32 with Arduino IDE eBook – Version 3.2 April 16, 2025

You must be logged in to view this content.

Contact Support - Refunds - Privacy - Terms - MakerAdvisor.com - Member Login

Copyright © 2013-2025 · RandomNerdTutorials.com · All Rights Reserved

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.