Skip to content

Instantly share code, notes, and snippets.

@5shekel
Forked from rw950431/read_thingspeak.py
Last active January 19, 2018 20:53
Show Gist options
  • Save 5shekel/de4e2ccb933791c863a044d98969dc9b to your computer and use it in GitHub Desktop.
Save 5shekel/de4e2ccb933791c863a044d98969dc9b to your computer and use it in GitHub Desktop.
Read last update from thingspeak
#!/usr/bin/env python
import urllib2,json
CHANNEL_ID=203342
def main():
conn = urllib2.urlopen("http://api.thingspeak.com/channels/%s/feeds/last.json" % (CHANNEL_ID))
response = conn.read()
print "http status code=%s" % (conn.getcode())
data=json.loads(response)
print "field1: ",data['field1']," ",data['created_at']
conn.close()
if __name__ == '__main__':
main()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment