flask neu in develop
This commit is contained in:
37
dht22/weather.py
Executable file
37
dht22/weather.py
Executable file
@@ -0,0 +1,37 @@
|
||||
#! /usr/bin/python3
|
||||
|
||||
from time import sleep
|
||||
import logging
|
||||
import Adafruit_DHT
|
||||
|
||||
__PIN__ = 4 # GPIO Pin, den wir nutzen
|
||||
__WAIT__ = 0.5 # Warten für 0,5 Sekunden
|
||||
|
||||
logging.basicConfig( format='%(asctime)-15s [%(levelname)s] %(funcName)s: %(message)s', level=logging.DEBUG)
|
||||
|
||||
def main():
|
||||
logging.debug('initialisiere Sensor')
|
||||
dht22_sensor = Adafruit_DHT.DHT22
|
||||
logging.debug(f'Sensor initialisiert ${dht22_sensor}')
|
||||
|
||||
while True:
|
||||
|
||||
logging.debug('lese von Sensor')
|
||||
feuchte, temp_c = Adafruit_DHT.read_retry(dht22_sensor, __PIN__)
|
||||
|
||||
logging.debug(f'rel. Feuchte: ${feuchte:.2f}, Temperatur: ${temp_c:.2f}°C')
|
||||
|
||||
|
||||
|
||||
if __name__ =='__main__':
|
||||
try:
|
||||
logging.debug('Programm startet')
|
||||
main()
|
||||
except KeyboardInterrupt:
|
||||
pass
|
||||
finally:
|
||||
pass
|
||||
|
||||
|
||||
|
||||
|
Reference in New Issue
Block a user