-
-
Save ToeJamson/5c4b5e99b6eb34665fb6 to your computer and use it in GitHub Desktop.
Tutorial: Building a Raspberry Pi Smart Home (Part 1)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
h,t = dht.read_retry(dht.DHT22, 4) | |
print 'Temp={0:0.1f}*C Humidity={1:0.1f}%'.format(t, h) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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