Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix dht.c error: can't read data from DHT 11 #485

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from

Conversation

ZhongUncle
Copy link

@ZhongUncle ZhongUncle commented Mar 28, 2024

Hello,
I notice when I use the example gpio/dht_sensor in right way, Pico can't read data from DHT11. It toke a night and after reading datasheet https://www.mouser.com/datasheet/2/758/DHT11-Technical-Data-Sheet-Translated-Version-1143054.pdf, I find this error according 2 errors:

  1. In Line 49~53, it doesn't set high signal after low signal and wait some time. MCU pulls up voltage and waits for DHT11 response (20-40us).
  2. In Line 73, the range of count (accumulated time) is 26~28, because 26~28 means data "0", If it is longer, it means data "1". But for redundancy, I choose 35 (I test it works well).

This is first time I find this error [Why DHT11 not work after some times using C in pico - Raspberry Pi Forums](https://forums.raspberrypi.com/viewtopic.php?t=355462l), in this post, I use USB and minicom on Mac.

Recently, I buy a Raspberry Pi 4B to re-test this error following the document Raspberry Pi Pico C/C++ SDK by UART, this error still exists. It displays:

截屏2024-03-28 23 07 16

The print's dislocation may be according to I ssh to raspberry pi. But the data from DHT11 also are 0, and print Bad data.

After fixing, it displays:
截屏2024-03-28 23 30 45

It works well.

@ZhongUncle ZhongUncle changed the title fix dht.c error: can read data from DHT 11 fix dht.c error: can't read data from DHT 11 Mar 28, 2024
@hasenradball
Copy link

@ZhongUncle have a look at:

I completly reworked this example, see:

a) PR #440
b) PR #450
c) https://github.com/hasenradball/AM2302-Sensor

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants