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