Skip to content

Instantly share code, notes, and snippets.

@misterhay misterhay/postPressure.py
Last active Aug 29, 2015

Embed
What would you like to do?
posting atmospheric pressure data from openweathermap.org
import requests
# fill in the appropriate values from your data.sparkfun.com data stream
publicKey = 'G2pKDamRDDUwKy7aMdy5'
privateKey = ''
dataLabel = 'pressure'
# Weather location, see openweathermap.org/current for more information
location = 'Edmonton,ca'
weatherUnits = 'metric'
# get weather data in JSON format
weatherUrl = 'http://api.openweathermap.org/data/2.5/forecast/daily?q=' + location + '&units=' + weatherUnits + '&cnt=1'
weather = requests.get(weatherUrl).json()
pressure = str(weather['list'][0]['pressure'])
# log the data
pushUrl = 'https://data.sparkfun.com/input/' + publicKey + '?private_key=' + privateKey + '&' + dataLabel + '=' + pressure
push = requests.get(pushUrl)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.