Wants to use the dht22

Hi,

I want to use the dht22, but when the hestia has started up, it looks like this is waiting for the bme280 even if the dht22 is connected.

I think there is still a config to be changed but I can not find which one.

Stef

Edit this file


Comment out the BME lines 4 and 9 and uncomment the DHT lines 2 and 7. Maybe restarting OpenHAB would be wise but if you don’t know how to do it, reboot the whole HestiaPi.

Please confirm :wink:

For the record, as far as I know OpenHAB will reparse all config files when they’re saved, no restart should be necessary. IIRC you can tail the logs in /var/log/openhab to see it pick up the changes.

Hi,

Thx for the reply,
I have now a new problem, what is the root pwd .
To edit this file it seems that I must go to the root dir but !!! that password ??

plz help.

stef

Use sudo -i and the normal user password to get a root shell.

See

pi and hestia are the username and password respectively.

Hello
I’m trying to get my DHT22 sensor working wit my hardware, but changing the two lines in default.things file didn’t work for me.
Did you managed to get your sensor working? Which pin of Raspi did you use?
Thanks for your help

Hello
I think I found the problem:
It’s a conjunction with Raspberry Zero W and DHT22 sensor. The Adafruit_DHT library check the version of board used by looking at cpuinfo. The newer CPU on Zero W is not recognised as a Raspberry CPU and a platform=None is returned. The process stops before starting the communication with the sensor.
Now the hard thing: how can I solve that? The library is packaged inside a .egg file where all the .py file are stored. I’ll take a look around to find a way to modify the library.
If someone have already a solution, you are welcome!

Well spotted! As DHT is not officially maintained any more we didnt check it with the W.
Does this solve the problem (in the last comment)?

Sorry, this will be a long reply…

I’m not sure if your ink solve the problem (I think is not the same origin, we are using python2 and that one is related to python3), but I found a solution myself.

From your link I saw the library used is now updated to version 1.3.2, we use 1.3.1. Not sure if the new version fix the 2 different bug I found (I checked now, they added the Raspberry Pi 3 family), but it is pretty simple to fix by ourself.

The first one is about in the platform_detect module of the library. It check for the CPU Hardware name in /proc/cpuinfo file, but the one for the Zero W is not listed as an option. I modified the if condition to match the BCM2835 processor of the W and this bug is gone.

The second one come out with next step. I modified the Hardware name to let the library think I’m using a Raspberry Pi 2, but the code fail to load a driver because an import statement have a misspelled name.

So, since the library is a simple .zip file renamed as .egg, you can copy the Adafruit_DHT-1.3.1-py2.7-linux-armv6l.egg library from /usr/local/lib/python2.7/dist-packages/ and uncompress it (you can use the python command
python -m zipfile -e /usr/local/lib/python2.7/dist-packages/Adafruit_DHT-1.3.1-py2.7-linux-armv6l.egg target-dir/).
Then you need to modify the files interested by the bugs:

  • platform_detect.py: change the very last block to
    elif match.group(1) == 'BCM2835':
    # Pi 2
    return 2

  • Raspberry_Pi_2.py: change the line
    from . import Raspberry_Pi_2_Driver as driver
    to
    from . import Raspberry_Pi_Driver as driver)

Now you can zip the whole folder again and overwrite the original one (you want to make a backup first). Again you can use the python command
python -m zipfile -c Adafruit_DHT-1.3.1-py2.7-linux-armv6l.egg Adafruit_DHT/

The new version from Adafruit seems to be more complex and I don’t think is a good idea trying to install that one. I can provide my modded library if someone needs it.

I hope this fix will help someone.

Bye!

1 Like

Sorry, I forgot two important things:

  • Adafruit recommends to use a 5V line as power and a 10Kohm resistor between data and 3.3V line. Sometimes 3.3V as power is not enough.
  • Uncommenting the DHT line on default.things is not enough to let the sensor work. As it is right now this thing is configured to work with sensor DHT11 on GPIO16, you need to change the command using 22 for DHT22 (instead of 11) and 2 for GPIO2 (assuming you connected the sensor on the same data pin as the BME sensor. Change it in GPIOn if you want to move to another pin)

Well done!
I don’t want to sound disrespectful but Im inclined to offer your findings in this post linked from our FAQ. The little difference between the cost of the DHT and BME sensor cannot justify the effort to keep updating both.

Can’t imagine a better place. And this way I discover the faq section and avoid stupid question.

It is not a matter of price, it’s the availability that change…

1 Like

Sorry to resuscitate this topic one more time, but my hestia have a DHT sensor and I can’t do anything else.
V10.3 drops the support for DHT sensor family, but as described here it is very simple to install the required library (scripts for reading are still available in V10.3).
I made a script for that, so you don’t have to filter the needed commands from the link:

sudo apt-get update && apt-get upgrade
sudo apt-get install build-essential python-pip python-dev python-smbus git
cd /home/pi/git/
git clone https://github.com/adafruit/Adafruit_Python_DHT.git
cd Adafruit_Python_DHT
sudo python setup.py install

@HestiaPi if you want to leave an AdafruitInstall.sh file with other Adafruit reading scripts, you can save someone time. Not a big problem, but after flash who needs DHT library can install it with only one command.

Thanks!