Adafruit_DHT11_test.py 451 B

123456789101112131415161718192021
  1. import time
  2. import Adafruit_DHT
  3. now = time.strftime("%Y.%m.%d %H:%M:%S")
  4. sensor = 11
  5. pin = 25
  6. interval = 5
  7. print "Datum Zeit \t Temperatur[*C] Luftfeuchte[%]"
  8. while True:
  9. start_loop_time = time.time()
  10. hum, temp = Adafruit_DHT.read_retry(sensor, pin)
  11. if hum is not None and temp is not None:
  12. print("%s\t %s\t %s" % (now, temp, hum))
  13. else:
  14. print "Fehler beim Auslesen des Sensors"
  15. time.sleep(interval - time.time() + start_loop_time)