DHT 11 on Raspberry 2

Moderator: leecollings

Spindi
Posts: 8
Joined: Sunday 05 February 2017 19:11
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: DHT 11 on Raspberry 2

Post by Spindi »

HI guys!

So I now tested it with the resistor and it's working well now!

Thanks a lot ijobain!!!!!!!!!
Kraod
Posts: 1
Joined: Saturday 18 March 2017 9:11
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: DHT 11 on Raspberry 2

Post by Kraod »

Hello
I tried the solution in this post and it worked marvelously.
I have a question though: the script is written for a single dht, but I will have 5 of them in my house; is there a way to implement more in the same script or do I need to make a script for each of them ?
toontoon
Posts: 2
Joined: Monday 17 April 2017 19:18
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: DHT 11 on Raspberry 2

Post by toontoon »

For many hours I have been trying to get DHT11 working onRaspberry. when I read manually sudo ./AdafruitDHT.py 11 4 no problems, good reading. But if I try to use the mentioned program I get the same error as journeyman
File "dht11.py", line 12
sleep 5
^
SyntaxError: invalid syntax

Does anyone know how to fix this?

thanx!
Pasibun
Posts: 10
Joined: Sunday 21 January 2018 19:03
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: DHT 11 on Raspberry 2

Post by Pasibun »

its been a year since some one posted something here.
But mayby some of you can help me out.
I got everything working except the bash script.
When i try to run the bash script i got this output:

Code: Select all

pi@raspberrypi:~ $ /home/pi/dev-domoticz/scripts/dht_22.sh
21.3
45.1
HTTP/1.1 401 Unauthorized
Content-Length: 91
Content-Type: text/html
Set-Cookie: SID=none; HttpOnly; Expires=Thu, 01 Jan 1970 00:00:00 GMT

<html><head><title>Unauthorized</title></head><body><h1>401 Unauthorized</h1></body></html
My bash script:

Code: Select all

#!/bin/sh
# Domoticz server
SERVER="10.0.0.110:8080"
# DHT IDX
DHTIDX="4"

# DHTPIN
DHTPIN="4"

# TEMP FILE
TMPFILE="/var/tmp/temp.txt"

cpt=0
while [ $cpt -lt 6 ]
do
TEMP=""

sleep 5

sudo nice -20 /home/pi/dev-domoticz/scripts/Adafruit_Python_DHT/examples/AdafruitDHT.py 22 $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://10.0.0.110:8080/json.htm?type=command&param=udevice&idx=$DHTIDX&nvalue=0&svalue=$TEMP;$HUM;2"

TEMP=""
HUM=""

#rm $TMPFILE
exit 0
#fi
#echo $cpt
cpt=$(($cpt+1))
done
exit 1
When i run this in the browser:

Code: Select all

http://10.0.0.110:8080/json.htm?type=command&param=udevice&idx=4&nvalue=0&svalue=21;40;2
i receive:

Code: Select all

{
   "status" : "OK",
   "title" : "Update Device"
}
Can some one help me out here?
Smartie
Posts: 21
Joined: Monday 14 December 2015 15:12
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: DHT 11 on Raspberry 2

Post by Smartie »

Hey,

it means that you have no login data used.

http://10.0.0.110:8080/json.htm?type=co ... ue=21;40;2
its wrong. better you use
127.0.0.1 or http://user:[email protected]:8080/js ... ue=21;40;2

thats work
Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest