DHT11 Help !!!

Moderator: leecollings

arhangel76
Posts: 22
Joined: Sunday 18 October 2020 21:39
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

DHT11 Help !!!

Post by arhangel76 »

Hello everybody,I tried different tutorials but I can't add this sensor DHT11 in domoticz,please help me with an updated tutorial.

I thank you from the bottom of my heart. :idea:
User avatar
kiddigital
Posts: 435
Joined: Thursday 10 August 2017 6:52
Target OS: Raspberry Pi / ODroid
Domoticz version: Beta
Location: Netherlands
Contact:

Re: DHT11 Help !!!

Post by kiddigital »

Please provide more details on your setup and how you have connected the sensor and which Domoticz hardware module you are trying to use for this.
One RPi with Domoticz, RFX433e, aeon labs z-wave plus stick GEN5, ha-bridge 5.4.0 for Alexa, Philips Hue Bridge, Pimoroni Automation Hat
One RPi with Pi foundation standard touch screen to display Dashticz
arhangel76
Posts: 22
Joined: Sunday 18 October 2020 21:39
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: DHT11 Help !!!

Post by arhangel76 »

ok,sorry for poor details,i use raspberry pi 3,and last version of domoticz,i succeed to conect and setup 4 5v relays and i need to add this sensor.
this is my conections:
vcc- +3,3v
gnd
signal - pin7
Attachments
2.jpg
2.jpg (36.16 KiB) Viewed 1547 times
1.jpg
1.jpg (53.58 KiB) Viewed 1547 times
Jan Jansen
Posts: 229
Joined: Wednesday 30 April 2014 20:27
Target OS: Raspberry Pi / ODroid
Domoticz version: Stable
Location: The Netherlands
Contact:

Re: DHT11 Help !!!

Post by Jan Jansen »

@arhangel76,

viewtopic.php?f=12&t=9531>>may help you further.
User avatar
kiddigital
Posts: 435
Joined: Thursday 10 August 2017 6:52
Target OS: Raspberry Pi / ODroid
Domoticz version: Beta
Location: Netherlands
Contact:

Re: DHT11 Help !!!

Post by kiddigital »

@arhangel76 ,

There are a few options/path you can look at. It does not work straight out of the box without doing anything.

There are a few 'hardware' modules to try:
- 1-Wire (System)
- generic sysgpio
- I2C sensors
- Raspberry GPIO sensors

Your sensor is not an I2C sensor and as far as I know not a (Dallas) 1-Wire compatible sensor, so I would guess to start with GPIO.

I know that I have a few sensor on my raspberry (the one that runs Domoticz) through a HAT board (Automation HAT) where Domoticz reads the data using the 'generic sysgpio' module. But therefor I have to 'configure' sysfs GPIO (tell which gpio pins have which function) at boot before starting Domoticz.

From the sourcecode of the 'Raspberry GPIO sensors': (Maybe start here?)

Code: Select all

Connection information:
	This hardware uses the pins of the Raspebrry Pi's GPIO port.
	Please read:
	http://wiringpi.com/pins/special-pin-functions/
	http://wiringpi.com/pins/ for more information
	As we cannot assume domoticz runs as root (which is bad), we won't take advantage of wiringPi's numbering.
	Consequently, we will always use the internal GPIO pin numbering as noted the board, including in the commands below

	Pins have to be exported and configured beforehand and upon each reboot of the Pi, like so:
	- For output pins, only one command is needed:
	gpio export <pin> out

	- For input pins, 2 commands are needed (one to export as input, and one to trigger interrupts on both edges):
	gpio export <pin> in
	gpio edge <pin> both

	Note: If you wire a pull-up, make sure you use 3.3V from P1-01, NOT the 5V pin ! The inputs are 3.3V max !
One RPi with Domoticz, RFX433e, aeon labs z-wave plus stick GEN5, ha-bridge 5.4.0 for Alexa, Philips Hue Bridge, Pimoroni Automation Hat
One RPi with Pi foundation standard touch screen to display Dashticz
arhangel76
Posts: 22
Joined: Sunday 18 October 2020 21:39
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: DHT11 Help !!!

Post by arhangel76 »

the idea is that in the command line it works perfectly what I want is to add it in the web page
User avatar
kiddigital
Posts: 435
Joined: Thursday 10 August 2017 6:52
Target OS: Raspberry Pi / ODroid
Domoticz version: Beta
Location: Netherlands
Contact:

Re: DHT11 Help !!!

Post by kiddigital »

Therefor one of the hardware modules should be able to read the sensor and put the readings into sensors.

Or do it yourself through scripts (using a Dummy sensor), see earlier suggestion.

The forum and Wiki have plenty examples.
One RPi with Domoticz, RFX433e, aeon labs z-wave plus stick GEN5, ha-bridge 5.4.0 for Alexa, Philips Hue Bridge, Pimoroni Automation Hat
One RPi with Pi foundation standard touch screen to display Dashticz
arhangel76
Posts: 22
Joined: Sunday 18 October 2020 21:39
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: DHT11 Help !!!

Post by arhangel76 »

So there is no exact tutorial for such a thing....
im beginer and i dont understand all....
User avatar
kiddigital
Posts: 435
Joined: Thursday 10 August 2017 6:52
Target OS: Raspberry Pi / ODroid
Domoticz version: Beta
Location: Netherlands
Contact:

Re: DHT11 Help !!!

Post by kiddigital »

Not that I know off, but maybe we can help one step at the time...

You say it works from the commandline. Can you show your command(s) and the output per command?
One RPi with Domoticz, RFX433e, aeon labs z-wave plus stick GEN5, ha-bridge 5.4.0 for Alexa, Philips Hue Bridge, Pimoroni Automation Hat
One RPi with Pi foundation standard touch screen to display Dashticz
arhangel76
Posts: 22
Joined: Sunday 18 October 2020 21:39
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

DHT11 Help !!!

Post by arhangel76 »

Ok i will post that...
Thank for try to help me
arhangel76
Posts: 22
Joined: Sunday 18 October 2020 21:39
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: DHT11 Help !!!

Post by arhangel76 »

ok look picture:

https://prnt.sc/v4sw0f
User avatar
kiddigital
Posts: 435
Joined: Thursday 10 August 2017 6:52
Target OS: Raspberry Pi / ODroid
Domoticz version: Beta
Location: Netherlands
Contact:

Re: DHT11 Help !!!

Post by kiddigital »

Ok, so you run a script. If you post the content of the script, than will tell use more.
One RPi with Domoticz, RFX433e, aeon labs z-wave plus stick GEN5, ha-bridge 5.4.0 for Alexa, Philips Hue Bridge, Pimoroni Automation Hat
One RPi with Pi foundation standard touch screen to display Dashticz
arhangel76
Posts: 22
Joined: Sunday 18 October 2020 21:39
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: DHT11 Help !!!

Post by arhangel76 »

#!/bin/sh

# Domoticz server
SERVER="127.0.0.1:8080"
# DHT IDX
DHTIDX="10"

# DHTPIN
DHTPIN="4"

sleep 5

sudo nice -20 python /home/root/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&param=udevice&idx=$DHTIDX&nvalue=0&svalue=$TE$
#echo curl -s -i -H "Accept: application/json" "http://$SERVER/json.htm?type=command&param=udevice&idx=$DHTIDX&nvalue=0&sval$

TEMP=""
HUM=""
User avatar
kiddigital
Posts: 435
Joined: Thursday 10 August 2017 6:52
Target OS: Raspberry Pi / ODroid
Domoticz version: Beta
Location: Netherlands
Contact:

Re: DHT11 Help !!!

Post by kiddigital »

arhangel76 wrote:

Code: Select all

#!/bin/sh

# Domoticz server
SERVER="127.0.0.1:8080"
# DHT IDX
DHTIDX="10"

# DHTPIN
DHTPIN="4"

sleep 5

sudo nice -20 python /home/root/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&param=udevice&idx=$DHTIDX&nvalue=0&svalue=$TE$
#echo curl -s -i -H "Accept: application/json" "http://$SERVER/json.htm?type=command&param=udevice&idx=$DHTIDX&nvalue=0&sval$

TEMP=""
HUM=""
Ok, your script look (almost) ok.
Can you show the Devices overview of Domoticz? Especially Device with idx 10 as your script uses that one?
One RPi with Domoticz, RFX433e, aeon labs z-wave plus stick GEN5, ha-bridge 5.4.0 for Alexa, Philips Hue Bridge, Pimoroni Automation Hat
One RPi with Pi foundation standard touch screen to display Dashticz
arhangel76
Posts: 22
Joined: Sunday 18 October 2020 21:39
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: DHT11 Help !!!

Post by arhangel76 »

do you mean this?

#! /bin/bash

printf "Set GPIO"
printf "\n"

#relay pos1
echo 17 > /sys/class/gpio/export
sudo sh -c "echo '1' >> /sys/class/gpio/gpio17/active_low"
echo high > /sys/class/gpio/gpio17/direction

#relay pos2
echo 27 > /sys/class/gpio/export
sudo sh -c "echo '1' >> /sys/class/gpio/gpio27/active_low"
echo high > /sys/class/gpio/gpio27/direction

#relay pos3
echo 22 > /sys/class/gpio/export
sudo sh -c "echo '1' >> /sys/class/gpio/gpio22/active_low"
echo high > /sys/class/gpio/gpio22/direction

#relay pos4
echo 23 > /sys/class/gpio/export
sudo sh -c "echo '1' >> /sys/class/gpio/gpio23/active_low"
echo high > /sys/class/gpio/gpio23/direction
exit 0
User avatar
kiddigital
Posts: 435
Joined: Thursday 10 August 2017 6:52
Target OS: Raspberry Pi / ODroid
Domoticz version: Beta
Location: Netherlands
Contact:

Re: DHT11 Help !!!

Post by kiddigital »

Not really, this is a different script. When do you run this script?

Please make a screenshot of Domoticz Device settings screen showing Device 10
One RPi with Domoticz, RFX433e, aeon labs z-wave plus stick GEN5, ha-bridge 5.4.0 for Alexa, Philips Hue Bridge, Pimoroni Automation Hat
One RPi with Pi foundation standard touch screen to display Dashticz
arhangel76
Posts: 22
Joined: Sunday 18 October 2020 21:39
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: DHT11 Help !!!

Post by arhangel76 »

User avatar
kiddigital
Posts: 435
Joined: Thursday 10 August 2017 6:52
Target OS: Raspberry Pi / ODroid
Domoticz version: Beta
Location: Netherlands
Contact:

Re: DHT11 Help !!!

Post by kiddigital »

arhangel76 wrote:

Code: Select all

#!/bin/sh

# Domoticz server
SERVER="127.0.0.1:8080"
# DHT IDX
DHTIDX="10"

# DHTPIN
DHTPIN="4"

sleep 5

sudo nice -20 python /home/root/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

Try changing this line:

Code: Select all

# Send data
curl -s -i -H "Accept: application/json" "http://$SERVER/json.htm?type=command&param=udevice&idx=$DHTIDX&nvalue=$TEMP&svalue=$TEMP
It sets the **nValue** (numeric) of the Sensor (sensor 10).

Also it also sends $TEMP instead of $TE$. (Is that a typo?)
One RPi with Domoticz, RFX433e, aeon labs z-wave plus stick GEN5, ha-bridge 5.4.0 for Alexa, Philips Hue Bridge, Pimoroni Automation Hat
One RPi with Pi foundation standard touch screen to display Dashticz
arhangel76
Posts: 22
Joined: Sunday 18 October 2020 21:39
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: DHT11 Help !!!

Post by arhangel76 »

probably the editing error
arhangel76
Posts: 22
Joined: Sunday 18 October 2020 21:39
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: DHT11 Help !!!

Post by arhangel76 »

Post Reply

Who is online

Users browsing this forum: No registered users and 0 guests