BeagleBone weather station
Here's a quick demo of PyBBIO's BMP183 and HTU21D libraries. This will push temperature, relative humidity, pressure and dew point data to ThingSpeak every 30 seconds.
import requests
from bbio import *
from bbio.libraries.BMP183 import BMP183
from bbio.libraries.HTU21D import HTU21D
bmp = BMP183(SPI0)
htu = HTU21D(I2C2)
API_KEY = "0000000000000000" # Put your write API here
def postData(*data):
url = "https://api.thingspeak.com/update"
params = {'api_key' : API_KEY}
for i in range(0, len(data)):
params['field%i' % (i+1)] = data[i]
print params
response = requests.post(url, params=params)
print response
def setup():
pass
def loop():
pressure = bmp.getPressure() / 1000.0 # in kPa
rh = htu.getHumidity()
temp = htu.getTemp()
dew_point = htu.calculateDewPoint(rh, temp)
postData(temp, rh, pressure, dew_point)
delay(30000)
run(setup, loop)
from bbio import *
from bbio.libraries.BMP183 import BMP183
from bbio.libraries.HTU21D import HTU21D
bmp = BMP183(SPI0)
htu = HTU21D(I2C2)
API_KEY = "0000000000000000" # Put your write API here
def postData(*data):
url = "https://api.thingspeak.com/update"
params = {'api_key' : API_KEY}
for i in range(0, len(data)):
params['field%i' % (i+1)] = data[i]
print params
response = requests.post(url, params=params)
print response
def setup():
pass
def loop():
pressure = bmp.getPressure() / 1000.0 # in kPa
rh = htu.getHumidity()
temp = htu.getTemp()
dew_point = htu.calculateDewPoint(rh, temp)
postData(temp, rh, pressure, dew_point)
delay(30000)
run(setup, loop)
This uses the requests library to send the data to Thingspeak every 30 seconds in HTTP POST requests using the ThingSpeak API. You'll need to create a ThingSpeak channel first, then replace "0000000000000000"
with the API key for your channel.
And here's the weather at Gray Cat Labs: https://thingspeak.com/channels/33102/