Skip to content

Instantly share code, notes, and snippets.

@misterhay
Last active August 29, 2015 14:15
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save misterhay/4658d61e6034c7702168 to your computer and use it in GitHub Desktop.
Save misterhay/4658d61e6034c7702168 to your computer and use it in GitHub Desktop.
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