Hi guys,
I’m looking for a solution to attach a dht22 on the same pi to monitor temperature in the cupboard that my media equipment is stored. I currently have a few Sonoff basics connected via mqtt so I know mosquito is working. I’ve tried many tutorials on mqtt and python and trawled the web for tutorials without any success. If anyone can point me in the write direction I’d appreciate it or maybe I’ll just go down the esp route.
hr3
(Harry)
June 26, 2018, 5:47pm
2
How can I get data of DHT22 that connected to GPIO on Raspberry running Openhab. I a new in Openhab. Please help me
https://raspberrypi.stackexchange.com/questions/44577/openhab-exec-binding-sh-file-for-dht22
I am trying to add a temperature sensor to openhab but i cant get data from the script when executing it in openhab.
[image]
The last image is form the terminal when openhab is running and not getting any data.
Thanks for any help
psyciknz
(Psyciknz)
June 26, 2018, 6:53pm
3
I assume you’re getting a value from the DHT and can see it in a terminal?
You’re not posting a lot of detail in where you are having an issue.
Josar
(Josar)
June 26, 2018, 7:24pm
4
Some info to the exec binding for openHAB2.0
This is a example thread to show how the exec binding 2.x works with detailed explanations.
This tutorial only works since openHAB 2.3.0 Build #1212.
I set up a fresh installation of “Raspbian GNU/Linux 9 (stretch)” and installed OpenHAB just followed my own thread and found some more information i missed at the first time. It is based on the Tutorial from here .
First make sure you connect your transmitter with the Raspberry like follows. Have a look at the RPI pinout .
Pin ATAD Data to 11 - …
This tutorial is based on this , this , this and a lot of threads and tutorials i had to read till i got it working.
I try to give a step by step Tutorial how to get a temperature chart with OpenHAB2 and the ExecBinding 2 using the RRD4J database for persistency.
I will not explain everything in detail, please read this post to get an basic understanding of how OpenHAB works. And use the tutorials and the manual to get deeper insight of how the different parts work.
Now to read out the CPU temp…
And a solution for the DHT22 which can be optimized but works.
It works now
I forgot to change the “Number” to “String”.
Thank you so much for your help. So This is my solution now:
items:
String Temp "Temperature [%.2f C]" <temperature> {channel="exec:command:temp:output"}
String Hum "Humidity [%d %%]" <humidity> {channel="exec:command:hum:output"}
scripts:
temp.py
#!/usr/bin/env python2.7
import sys
import Adafruit_DHT
sensor = Adafruit_DHT.DHT22
pin = 18
humidity, temperature = Adafruit_DHT.read_retry(sensor, pin)
if humidit…
1 Like
Thanks for the tips. I managed to get it working, thought it was the code but actually it was mosquito that needed a reinstall.