Bosse_B
Posts: 689
Joined: Thu Jan 30, 2014 9:53 am

AM2302 DHT sensor on RPi3 not working after reboot of RPi

Thu Oct 18, 2018 5:49 am

I have discovered a strange problem with a sensor I am deploying to my summer home in order to monitor temp/humidity over the winter.
I have an RPi3 with the Adafruit_Python_DHT library installed and it worked just fine yesterday.

Now following the nightly reboot of the RPi it has stopped working, no values can be detected.
After some research I power cycled the sensor by pulling the connection from the 3.3V pin on the GPIO connector.
Then I reinserted it (all with the Pi still running) and now the sensor works again and the "./AdafruitDHT.py 22 4" call returns the expected values.

Clearly this will not work for monitoring house temperatures over the winter, so I am wondering how to solve the problem?

The nightly Pi reboot is there to guarantee that it is accessible and working even though no human can reach it for 6 months, so it cannot be removed.
According to installation instructions I have enabled the RPi I2C, SPI and 1Wire interfaces. I don't know if they are needed or if they can interfere...

Is there a problem using GPIO4 as the connection for the DHT sensor?
Which of the interfaces above can possibly interfere and is really not needed (if any)? (I will disable it if not needed)

It seems like a cron initiated reboot hangs the DHT sensor for some reason whereas an RPi power cycle does not....
Bo Berglund
Sweden

User avatar
joan
Posts: 13622
Joined: Thu Jul 05, 2012 5:09 pm
Location: UK

Re: AM2302 DHT sensor on RPi3 not working after reboot of RPi

Thu Oct 18, 2018 7:36 am

The last time I checked the 1-wire bus defaults to using GPIO 4.

Bosse_B
Posts: 689
Joined: Thu Jan 30, 2014 9:53 am

Re: AM2302 DHT sensor on RPi3 not working after reboot of RPi

Thu Oct 18, 2018 7:39 am

Is it needed for the Adafruit DHT interface?
Is it somehow outputting data during boot that can lock up the DHT sensor?
Bo Berglund
Sweden

Bosse_B
Posts: 689
Joined: Thu Jan 30, 2014 9:53 am

Re: AM2302 DHT sensor on RPi3 not working after reboot of RPi

Fri Oct 19, 2018 10:40 am

I thought that the problem was fixed by running the call to the py script as sudo (from AdaFruit's installation page), but unfortunately this was not the case. When I checked the log file I found that after a few successful measurements the DHT seemed to have locked up again and there was no output anymore.
So I had to abandon the over-winter temp logging of the summer house since we were leaving the location... :cry:

Still I wonder if the fact that I enabled the I2C, SPI and 1Wire interfaces on my RPi is the cause of the malfunction?
Are those interfaces really needed for the Adafruit_Python_DHT to work?
AdaFruit do not mention it on their page....
Bo Berglund
Sweden

Bosse_B
Posts: 689
Joined: Thu Jan 30, 2014 9:53 am

Re: AM2302 DHT sensor on RPi3 not working after reboot of RPi

Sat Oct 20, 2018 5:34 am

I have switched GPIO pin to use GPIO17 instead of GPIO4.
Now the logging is not giving up, so it seems like GPIO4 (which is also used by the 1wire system) is not usable. At least not when 1wire is enabled....
The cron job has successfully operated every 30 minutes over night and across a scheduled RPi reboot.
Strange.
Bo Berglund
Sweden

Bosse_B
Posts: 689
Joined: Thu Jan 30, 2014 9:53 am

Re: AM2302 DHT sensor on RPi3 not working after reboot of RPi

Sun Oct 21, 2018 9:20 am

And yesterday I disabled (using sudo raspi-config) the 1Wire, I2C and SPI interfaces, which I previously enabled because of the instructions on this webpage.
After this I switched back the cron job to using GPIO4 and waited.
Turns out that now the RPi has performed a reading every 30 minutes for over 12 hours also across a reboot and all without a hitch!
So the advice on the page is clearly misleading regarding enabling the interfaces!
Too bad because now I will not get the over-winter temp registrations....
Bo Berglund
Sweden

User avatar
joan
Posts: 13622
Joined: Thu Jul 05, 2012 5:09 pm
Location: UK

Re: AM2302 DHT sensor on RPi3 not working after reboot of RPi

Sun Oct 21, 2018 9:46 am

This highlights the importance of always doing your own research, even if you end up using a solution from a web site.

The DHT22 sensor is packaged into various modules. One of these modules may be read using the I2C bus. None of the DHT22 sensor modules may be read using the SPI or the (Dallas) 1-wire bus interface.

There is understandable confusion between the 1-wire bus and the DHT22, as the DHT22 uses a so called one wire interface (one data line). However the (Dallas) 1-wire bus is a one wire interface designed by Dallas and is incompatible with the DHT22 one wire interface.

Return to “General discussion”