Browse Source

Erstellung des Repository

fstange 5 years ago
parent
commit
f78e0cbd83
1 changed files with 21 additions and 0 deletions
  1. 21 0
      Adafruit_DHT11_test.py

+ 21 - 0
Adafruit_DHT11_test.py

@@ -0,0 +1,21 @@
+import time
+import Adafruit_DHT
+
+now = time.strftime("%Y.%m.%d %H:%M:%S")
+
+sensor = 11
+pin = 25
+interval = 5
+
+print "Datum Zeit \t Temperatur[*C] Luftfeuchte[%]"
+
+while True:
+	start_loop_time = time.time()
+
+	hum, temp = Adafruit_DHT.read_retry(sensor, pin)
+	if hum is not None and temp is not None:
+		print("%s\t %s\t %s" % (now, temp, hum))
+	else:
+    		print "Fehler beim Auslesen des Sensors"
+
+	time.sleep(interval - time.time() + start_loop_time)