You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
37 lines
783 B
37 lines
783 B
#! /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
|
|
|
|
|
|
|
|
|
|
|