Skip to content

Instantly share code, notes, and snippets.

@lucasrangit
Last active August 29, 2015 14:25
Show Gist options
  • Save lucasrangit/d3415f8ce00d77d21026 to your computer and use it in GitHub Desktop.
Save lucasrangit/d3415f8ce00d77d21026 to your computer and use it in GitHub Desktop.
Photon analogRead
import urllib, urllib2
import json
from secrets import device_id, access_token
url = 'https://api.particle.io/v1/devices/'+device_id+'/analogread'
values = {
'params' : 'A0',
'access_token' : access_token,
}
data = urllib.urlencode(values)
req = urllib2.Request(url, data)
response = urllib2.urlopen(req)
the_page = response.read()
print(the_page)
the_json = json.loads(the_page)
print(the_json['return_value'])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment