Upload fcuway_195.py
Browse files- fcuway_195.py +23 -0
fcuway_195.py
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# -*- coding: utf-8 -*-
|
| 2 |
+
"""fcuWay.195
|
| 3 |
+
|
| 4 |
+
Automatically generated by Colab.
|
| 5 |
+
|
| 6 |
+
Original file is located at
|
| 7 |
+
https://colab.research.google.com/drive/1_wM8-D2155uGbQp3IrrSrFyx5QDsAq7J
|
| 8 |
+
"""
|
| 9 |
+
|
| 10 |
+
import RPi.GPIO as GPIO
|
| 11 |
+
import dht11
|
| 12 |
+
import time
|
| 13 |
+
GPIO.setmode(GPIO.BCM)
|
| 14 |
+
myDHT=dht11.DHT11(pin=17)
|
| 15 |
+
try:
|
| 16 |
+
while True:
|
| 17 |
+
result=myDHT.read()
|
| 18 |
+
if result.is_valid():
|
| 19 |
+
print('Temperature is:', result.temperature,'Humidity is: ',result.humidity)
|
| 20 |
+
time.sleep(.2)
|
| 21 |
+
except KeyboardInterrupt:
|
| 22 |
+
GPIO.cleanup()
|
| 23 |
+
print('GPIO Ready to Perform')
|