DHT22

Moderator: leecollings

Post Reply
FredZ
Posts: 30
Joined: Monday 08 June 2020 6:41
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

DHT22

Post by FredZ »

Hello all

I'm attempting to get a DHT22 working with domoticz using this scrip. However it isn't working for me. And as I'm not a programmer I don't know how to debug it.

I've entered all the relavent data into the parameters sections

I fixed the first line

Code: Select all

#!/usr/bin/python
I now get the following error when I run the script.

Code: Select all

    if r.status_code! = 200:
                    ^
SyntaxError: invalid syntax
I'm hoping I can get this going. Seems that a lot of people are attempting the same thing, or have attempted it and given up for various reasons.

Any thoughts or comments would be most helpful.

Regards

Fred
User avatar
waaren
Posts: 6028
Joined: Tuesday 03 January 2017 14:18
Target OS: Linux
Domoticz version: Beta
Location: Netherlands
Contact:

Re: DHT22

Post by waaren »

FredZ wrote: Thursday 16 July 2020 5:47 I now get the following error when I run the script.

Code: Select all

    if r.status_code! = 200:
                    ^
SyntaxError: invalid syntax
try

Code: Select all

    if r.status_code != 200:
Debian buster, bullseye on RPI-4, Intel NUC.
dz Beta, Z-Wave, RFLink, RFXtrx433e, P1, Youless, Hue, Yeelight, Xiaomi, MQTT
==>> dzVents wiki
FredZ
Posts: 30
Joined: Monday 08 June 2020 6:41
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: DHT22

Post by FredZ »

Thanks for that.

Code: Select all

if r.status_code != 200:
Now I get the following error

Code: Select all

    print "Domoticz API error"
                             ^
SyntaxError: Missing parentheses in call to 'print'. Did you mean print("Domoticz API error")?
So I added the brackets

Code: Select all

print ("Domoticz API error")
Then I get the following error

Code: Select all

    url + = '& nvalue = 0 & svalue ='
          ^
SyntaxError: invalid syntax
Now I get the feeling something is actually wrong with the script.

Regards

Fred
User avatar
boum
Posts: 135
Joined: Friday 18 January 2019 11:31
Target OS: Raspberry Pi / ODroid
Domoticz version: 4.10717
Location: France
Contact:

Re: DHT22

Post by boum »

FredZ wrote: Thursday 16 July 2020 19:38 Then I get the following error

Code: Select all

    url + = '& nvalue = 0 & svalue ='
          ^
SyntaxError: invalid syntax
Now I get the feeling something is actually wrong with the script.
FredZ wrote: Thursday 16 July 2020 5:47 I'm attempting to get a DHT22 working with domoticz using this script. However it isn't working for me. And as I'm not a programmer I don't know how to debug it.
Except for the print parenthesis which is because of writing for an older Python interpreter, the script looks fine.
Check on the webpage, none of those space characters are present! It might be some copy/paste or formatting snafu. Check your editor, double-check for any other modifications between source and your copy.
User avatar
ILoveIOT
Posts: 59
Joined: Sunday 25 March 2018 17:47
Target OS: Linux
Domoticz version: 2020.2
Location: NL
Contact:

Re: DHT22

Post by ILoveIOT »

1x OPI PC 5.8.16 Debian 10, MiniDNLA,SMD230,EpEver,MPD,800GB,Wiegand,7 temps,DHT,32/64 I/O,2022.1
2x OPI PC 4.19.25 Debian 9, MPD,7 temps,16/32 I/O,BMP,4.10717
1x IntelNUC 5.10 Debian 10, 2TB,DalyBMS,2023.1
3x ESPEasy NodeMCU V3, 16/16 I/O
FredZ
Posts: 30
Joined: Monday 08 June 2020 6:41
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: DHT22

Post by FredZ »

I have discovered the issue.

As the original url is in french, I had google translate it. During the translation google has meesed with spacings.

I copied the code in its native form, then translated the text to english after.

All working.

I most appreciate the help/pointers

Regards

Fred
Freelance
Posts: 10
Joined: Wednesday 07 October 2020 12:34
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: DHT22

Post by Freelance »

Hi guys,
i got this working as well, but the temperature reading happens only once after i run the command python 2302.py where 2302.py is the script from the french site.

How can i get Domoticz to read the sensor all the time? Do i need to loop the script and how to do that?
FredZ
Posts: 30
Joined: Monday 08 June 2020 6:41
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: DHT22

Post by FredZ »

I have a better solution to the above.

I ended up using a NodeMCU and installed EasyESP wich has many plugins including for the DHT?? series of temp sensors. It also talks to Domoticz directly.

So now I leave my Domoticz box inside and the sensors are where they need to be as remote sensors.

Regards

Fred
Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest