Now its working...
The DHT 11 Script from here Dosnt work for me.
So i have change a lot from the script here at the Forum
other post: viewtopic.php?f=12&t=2006
To Install
(Pin1) 3,3V
(Pin6) GND
(Pin4) GPIO
reeding at the other Post
Login SSH
sudo apt-get update
sudo apt-get upgrade
sudo apt-get install build-essential python-dev python-openssl build-dep git nano
cd home/pi/domoticz/scripts
git clone https://github.com/adafruit/Adafruit_Python_DHT.git && cd Adafruit_Python_DHT
sudo python setup.py install
cd examples
now Check that it works:
$ sudo ./AdafruitDHT.py 11 4
Temp=24.0* Humidity=41.0%
If it works so its right.
now we make a dht11.sh to loop
First add a Dummy Switch at Domticz and see the IDX Number
then go back to the shell and make the script.
sudo nano dht_11.sh
now add the follow script:
Code: Select all
#!/bin/sh
# Domoticz server
SERVER="127.0.0.1:8080"
# DHT IDX
DHTIDX="26"
# DHTPIN
DHTPIN="4"
sleep 5
sudo nice -20 python /home/pi/domoticz/scripts/Adafruit_Python_DHT/examples/AdafruitDHT.py 11 $DHTPIN > /var/tmp/temp.txt
#TEMP=$(cat /var/tmp/temp.txt | grep "Temp" | awk '{ print $3 }')
#TEMP=$(cat /var/tmp/temp.txt | grep "Temp")
TEMP=$(awk ' /Temp/ {print substr ($0,6,4)}' /var/tmp/temp.txt)
#HUM=$(awk ' /Hudmidity/ {print substr ($0,0)}' /var/tmp/temp.txt)
#HUM=$(awk ' /Humidity/ {print 1$}' /var/tmp/temp.txt)
HUM=$(awk ' /Humidity/ {print substr ($0,22,4)}' /var/tmp/temp.txt)
echo $TEMP
echo $HUM
# Send data
curl -s -i -H "Accept: application/json" "http://$SERVER/json.htm?type=command¶m=udevice&idx=$DHTIDX&nvalue=0&svalue=$TE$
#echo curl -s -i -H "Accept: application/json" "http://$SERVER/json.htm?type=command¶m=udevice&idx=$DHTIDX&nvalue=0&sval$
TEMP=""
HUM=""
Then STRG + O to save and STRG + X to go out from the editor mode.
Then add a Crontab with Crontab -e
add follow command
*/5 * * * * /home/pi/domoticz/scripts/dht_11.sh
save with STRG +O and exit with STRG + X
Now the cronjob refresh every 5 Minutes the Temp