This shows you the differences between two versions of the page.
| Next revision | Previous revision | ||
| dh22 [2021/12/14 21:32] – created admin | dh22 [2021/12/19 20:07] (current) – admin | ||
|---|---|---|---|
| Line 1: | Line 1: | ||
| - | ====== DH22 ====== | + | ====== DH22 - HomeAssistant |
| + | |||
| + | Get values (temperature and humidity) from DH22, round the values and send it to HomeAssistant | ||
| <code python> | <code python> | ||
| - | #!/usr/bin/python | + | #!/usr/bin/python3 |
| - | import os, sys | ||
| import Adafruit_DHT | import Adafruit_DHT | ||
| import time | import time | ||
| import requests | import requests | ||
| - | import html | ||
| def sendData(name, | def sendData(name, | ||
| Line 22: | Line 22: | ||
| sensor = Adafruit_DHT.DHT22 | sensor = Adafruit_DHT.DHT22 | ||
| - | # The GPIO17 - Board number | + | # The GPIO17 - Board number |
| - | pin = '17' | + | pin = '2' |
| humidity, temperature = Adafruit_DHT.read_retry(sensor, | humidity, temperature = Adafruit_DHT.read_retry(sensor, | ||
| Line 31: | Line 31: | ||
| now = time.strftime(' | now = time.strftime(' | ||
| - | sendData(' | + | sendData(' |
| - | sendData(' | + | sendData(' |
| print('" | print('" | ||