Skip to content

Instantly share code, notes, and snippets.

@ToeJamson
Created August 3, 2015 21:45
Show Gist options
  • Save ToeJamson/5c4b5e99b6eb34665fb6 to your computer and use it in GitHub Desktop.
Save ToeJamson/5c4b5e99b6eb34665fb6 to your computer and use it in GitHub Desktop.
Tutorial: Building a Raspberry Pi Smart Home (Part 1)
h,t = dht.read_retry(dht.DHT22, 4)
print 'Temp={0:0.1f}*C Humidity={1:0.1f}%'.format(t, h)
import os
import time
import sys
from Pubnub import Pubnub
import Adafruit_DHT as dht
pubnub = Pubnub(publish_key='demo', subscribe_key='demo')
channel = 'pi-house'
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)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment