Skip to content

Instantly share code, notes, and snippets.

@banasrini
Created July 22, 2015 18:30
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 banasrini/215e2fed599f9ebee0c9 to your computer and use it in GitHub Desktop.
Save banasrini/215e2fed599f9ebee0c9 to your computer and use it in GitHub Desktop.
import os
import time
import sys
from Pubnub import Pubnub
import Adafruit_DHT as dht
pubnub = Pubnub(publish_key='demo', subscribe_key='demo')
h,t = dht.read_retry(dht.DHT22, 4)
temp='{0:0.1f}'.format(t)
hum='{0:0.1f}'.format(h)
message = {'temperature': temp, 'humidity': hum}
pubnub.publish(channel=channel, message=message, callback=callback, error=callback)
h,t = dht.read_retry(dht.DHT22, 4)
print 'Temp={0:0.1f}*C Humidity={1:0.1f}%'.format(t, h)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment