Skip to content

Instantly share code, notes, and snippets.

@mid0111
Created February 5, 2017 03:13
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 mid0111/ed429d977414ffe3b63c5777242193fb to your computer and use it in GitHub Desktop.
Save mid0111/ed429d977414ffe3b63c5777242193fb to your computer and use it in GitHub Desktop.
#!/usr/bin/python
# -*- coding: utf-8 -*-
from time import sleep
import sys
import Adafruit_DHT
import ambient
pin = 23
ambi = ambient.Ambient(970, "bb04bfa265692394")
while True:
humidity, temperature = Adafruit_DHT.read_retry(Adafruit_DHT.AM2302, pin)
if humidity is not None and temperature is not None:
r = ambi.send({"d1": temperature, "d2": humidity})
print 'Status code: %d' % r.status_code
sleep(10)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment