-
-
Save domadev812/d915fa10153d9d75ada3686e88d0ae4b to your computer and use it in GitHub Desktop.
Tutorial: Building a Raspberry Pi Smart Home (Part 1)
This file contains hidden or 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 hidden or 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 | |
| import Adafruit_DHT as dht | |
| from pubnub.pnconfiguration import PNConfiguration | |
| from pubnub.pubnub import PubNub | |
| pnconfig = PNConfiguration() | |
| pnconfig.subscribe_key = 'demo' | |
| pnconfig.publish_key = 'demo' | |
| pubnub = PubNub(pnconfig) | |
| channel = 'pi-house' |
This file contains hidden or 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).async(my_publish_callback) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment