Skip to content

Instantly share code, notes, and snippets.

@gvenzl
Last active January 1, 2020 01:04
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save gvenzl/af524e22f69ba3dab021e84ca1df4c88 to your computer and use it in GitHub Desktop.
Save gvenzl/af524e22f69ba3dab021e84ca1df4c88 to your computer and use it in GitHub Desktop.
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