Skip to content

Instantly share code, notes, and snippets.

@pgmot
Created July 16, 2017 02:58
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 pgmot/050c73e8fa2cc549d940ebc8d688601e to your computer and use it in GitHub Desktop.
Save pgmot/050c73e8fa2cc549d940ebc8d688601e to your computer and use it in GitHub Desktop.
#!/usr/bin/python
import sys
import Adafruit_DHT
from datetime import datetime
sensor = Adafruit_DHT.AM2302
pin = 17
humidity, temperature = Adafruit_DHT.read_retry(sensor, pin)
time = datetime.now().strftime('%s')
if humidity is not None and temperature is not None:
print('room.temperature\t{0}\t{1}'.format(temperature, time))
print('room.humidity\t{0}\t{1}'.format(humidity, time))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment