Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Grove Temperature & Humidity Sensor Pro Python script
#!/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