4:52 pm


Silver
March 18, 2016

CheerLights is a project where devices read data from the ThingSpeak channel 1417. That might point you in the right direction.
Also, this library looks to be API complete. You can read and write to ThingSpeak channels.
https://github.com/ninjawil/pythingspeak
The problem is that there are zero examples with the lib.
What version of Python are you using?
11:37 pm


Top
January 29, 2014

Basic example using standard python libraries, fetching last update from a given channel. (also at https://gist.github.com/rw950431/d186bb72f7d531b76a0b in case the forum mucks up the indentation)
See https://au.mathworks.com/help/thingspeak/get-a-channel-feed.html for other variants.
import urllib2,json
READ_API_KEY='your_read_api_key'
CHANNEL_ID=<your channel id>
def main():
conn = urllib2.urlopen("http://api.thingspeak.com/channels/%s/feeds/last.json?api_key=%s" \
% (CHANNEL_ID,READ_API_KEY))
response = conn.read()
print "http status code=%s" % (conn.getcode())
data=json.loads(response)
print data['field1'],data['created_at']
conn.close()
if __name__ == '__main__':
main()
6:11 pm


Silver
March 18, 2016

3:40 am

June 7, 2016

3:22 am


Top
January 29, 2014

If you wish to read data continuously you have 2 options
1. Wrap the above code in a loop that continually re-reads the data after a delay (at least 15 seconds, possibly more depending on your data).
2. If you have an internet-accessible device set it up as a HTTP server and set up a thingspeak react to push the data out to your device. This will (obviously) require much different code to the above.
Unfortunately, no matter how nicely everyone asks, thingspeak does not yet support MQTT or similar pub/sub protocols that would make this task very easy.
Most Users Ever Online: 166
Currently Online:
29 Guest(s)
Currently Browsing this Page:
1 Guest(s)
Top Posters:
rw950431: 272
Vinod: 240
piajola: 95
turgo: 70
vespapierre: 63
Adarsh_Murthy: 62
Member Stats:
Guest Posters: 1
Members: 8665
Moderators: 1
Admins: 2
Forum Stats:
Groups: 3
Forums: 14
Topics: 1600
Posts: 5760
Newest Members:
estebanmateo93, mikewrite, onlinebusiness, winzy99, Zark_zeugan, StefanWiModerators: cstapels: 460
Administrators: Hans: 405, lee: 457