Skip to content

Instantly share code, notes, and snippets.

Created December 6, 2014 05:50
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
What would you like to do?
Room temp with python and phant on a beaglebone black
#!/usr/bin/env python
import phant
import time
import pywapi
import Adafruit_BBIO.ADC as ADC
# from
# Set up phant
p = phant.Phant('public_key', 'temp',
'internettemp', private_key='xxxxx')
while True:
#read_raw returns non-normalized value
# Read the value from pin 36
# Voltage in mv
fakevoltage = ADC.read_raw("P9_36")
# Read it twice to get the actual value
# Due to a glitch in BBIO
voltage = ADC.read_raw("P9_36")
#print voltage
tempc = voltage / 10
print tempc
# Get weather from the internet
#use for zip code 80918
weather_com_result = pywapi.get_weather_from_weather_com('80918')
print "Internet Error"
wtemp = 0
#get temperature from internet and convert to int
wtemp = int(weather_com_result['current_conditions']['temperature'])
print wtemp
print "Temperature Error"
wtemp = 0
# Send data to phant
p.log(tempc, wtemp)
# Sleep for 10 minutes
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment