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

DHT22 report null after a while #40

Open
beneton2003 opened this issue Mar 23, 2020 · 12 comments
Open

DHT22 report null after a while #40

beneton2003 opened this issue Mar 23, 2020 · 12 comments
Labels

Comments

@beneton2003
Copy link

beneton2003 commented Mar 23, 2020

BUG DESCRIPTION
Hello *. I have a problem with my DHT22. After some time (hours, days) I get null values from sensor. So I attached 2 sensors to my raspberry pi via GPIO2, 27.

The results are confusing:
If one sensors show null, one other may keep reporting good values!
Reboot of rpi does not help at all.
Hard reset (Power off / on) of rpi always works.
Power reset (3.3-5V off / on) of a sensor only SOMETIMES works.
Data reset (pull cable and replug) of sensor works almost always.
If data reset (on ONE sensor) works, other null sensor will start reporting good values as well!

EXPECTED BEHAVIOR
Get both values.

THE SAME ISSUES
I had found the same issue on github
arendst/Tasmota#5619
Those guiys was make some change in reading algorythm, i was try to make the same changes, but i found that i can't make any changes to
/usr/local/lib/python3.7/dist-packages/adafruit_blinka/microcontroller/bcm283x/pulseio/libgpiod_pulsein
i'm not sure if i am going right way.
I think those guys find a way out
arendst/Tasmota#7440

@beneton2003
Copy link
Author

beneton2003 commented Mar 23, 2020

If I add a print(pulses) around line 178 (file /usr/local/lib/python3.7/dist-packages/adafruit_dht.py), I see:
image

if i make hard reset or data cable reset, everything will works fine for about 12 hours, maybe 10, sometimes more or less

@beneton2003
Copy link
Author

I was also try to uncomment debug flag in /usr/local/lib/python3.7/dist-packages/adafruit_blinka/microcontroller/bcm283x/pulseio/PulseIn.py

image

as we can see libgpiod_pulsein return empty value, i am not sure why is this happens, as i see the commands make right
['/usr/local/lib/python3.7/dist-packages/adafruit_blinka/microcontroller/bcm283x/pulseio/libgpiod_pulsein', '--pulses', '81', '--queue', '10318', '-i', 'gpiochip0', '2']

['/usr/local/lib/python3.7/dist-packages/adafruit_blinka/microcontroller/bcm283x/pulseio/libgpiod_pulsein', '--pulses', '81', '--queue', '20924', '-i', 'gpiochip0', '27']

I was trying to execute them in bash (without brakets and others), but nothing happens

@jnt2007
Copy link

jnt2007 commented Apr 16, 2020

What brand of sensors are you using? Asair or Aosong?

@beneton2003
Copy link
Author

I use both asair and aosong, but asair have a troubles, should i change it with aosong?

@jnt2007
Copy link

jnt2007 commented Apr 16, 2020

I have problems with Asair too. So I changed it to Aosong and problem not reproduced more than one month

@kattni
Copy link

kattni commented May 4, 2020

@beneton2003 @jnt2007 It appears that Adafruit sells the Aosong branded sensor. Where did you purchase the Asair sensor?

@jnt2007
Copy link

jnt2007 commented May 5, 2020

On Ebay or Aliexpress, sent from China. Frequently Asair sensor has a little bit lowest price.

@mryshakow
Copy link

mryshakow commented May 23, 2020

I have the same issue with both Asair and Aosong... only reconnecting the sensor will bring it back alive. This is super annoying. Can I provide more information to resolve this issue?

RPi3
DHT22 connected via 1,5m cable
DHT22 connected to 5V
Pull Up Resistor 10K
Read every 5 seconds

// Edit:

I can determine that the false behaviour only occurs (Not every time, not all sensor at that time) when another GPIO is switched... In my case its a relay on a relay board that is controlled via Pi4J in an indipendand micro service.

@evaherrada evaherrada added the bug label Jun 30, 2020
@evaherrada
Copy link
Collaborator

I can determine that the false behaviour only occurs (Not every time, not all sensor at that time) when another GPIO is switched... In my case its a relay on a relay board that is controlled via Pi4J in an indipendand micro service.

@mryshakow Good job noticing that. That should make it much easier to solve this.

@evaherrada evaherrada self-assigned this Jul 14, 2020
@evaherrada
Copy link
Collaborator

evaherrada commented Jul 14, 2020

@mryshakow Are you using the configuration that needs pulseio?

Edit: Looks like both setups need pulseio, which I don't think should be the case

@evaherrada
Copy link
Collaborator

@mryshakow I wasn't able to fully reproduce the error, but I think I may have found the culprit.

Can you comment out lines 37-42 of adafruit_dht.py?

It should look something like this when you're done
comment

Then, make sure it's setup like this. That way will do bit-banging instead of using pulseio. Basically, just hook up the resistor like in the picture, take the power to 3.3v, the ground to ground, and the data wire to whichever gpio pin you've been using.
weather_m0_dht_bb

Let me know if that works.

@evaherrada evaherrada removed their assignment Sep 17, 2020
@foarsitter
Copy link

foarsitter commented Nov 23, 2020

I can determine that the false behaviour only occurs (Not every time, not all sensor at that time) when another GPIO is switched... In my case its a relay on a relay board that is controlled via Pi4J in an indipendand micro service.

Experiencing the same with a relay and an AM2302. Can a "back electromotive force" be the problem: https://raspberrypi.stackexchange.com/questions/44060/dht22-temp-sensor-randomly-dropping/44109#44109?

Update: in my setup I have a refrigerator. When the compressors was turned off by the refrigerator thermostat the AM2302 stopped working. I'm now controlling the refrigerator by a relay and do not experience trouble anymore. So in my situation it was not a software related problem but an electrical one. Consider adding a transistor to you setup so you can toggle the power of the sensor when needed.

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

No branches or pull requests

6 participants