Last active
January 1, 2020 01:04
-
-
Save gvenzl/af524e22f69ba3dab021e84ca1df4c88 to your computer and use it in GitHub Desktop.
Grove Temperature & Humidity Sensor Pro Python script
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/python3 | |
# Press [Ctrl]+[C] to terminate the program | |
import seeed_dht | |
sensor = seeed_dht.DHT(seeed_dht.DHT.DHT_TYPE["DHT22"], 12) # DHT type 22, pin 12 | |
try: | |
while True: | |
humi, temp = sensor.read() | |
print('DHT{0}, humidity {1:.1f}%, temperature {2:.1f}C'.format(sensor.dht_type, humi, temp)) | |
except KeyboardInterrupt: | |
print("Exiting program.") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment