Last active
August 29, 2015 14:15
-
-
Save misterhay/4658d61e6034c7702168 to your computer and use it in GitHub Desktop.
posting atmospheric pressure data from openweathermap.org
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 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