Thingspeak
From emboxit
Contents
Thingspeak
Simplest possible example
Send data
- [
- Send data 4 times to private channel 7742/field1 with key XCASH390WFIB81H9 :
http://api.thingspeak.com/update?key=XCASH390WFIB81H9&field1=55 http://api.thingspeak.com/update?key=XCASH390WFIB81H9&field1=66 http://api.thingspeak.com/update?key=XCASH390WFIB81H9&field1=77 http://api.thingspeak.com/update?key=XCASH390WFIB81H9&field1=88
Retreive data
- Retrieve data from private channel:
https://www.thingspeak.com/channels/7742/feed.json?key=XCASH390WFIB81H9
{"channel":{"created_at":"2013-09-30T14:47:51Z","field1":"Field Label 1","id":7742,"last_entry_id":5,"name":"Channel 7742","updated_at":"2013-10-01T09:28:08Z"},"feeds":[{"created_at":"2013-10-01T09:20:45Z","entry_id":1,"field1":null},{"created_at":"2013-10-01T09:21:41Z","entry_id":2,"field1":"55"},{"created_at":"2013-10-01T09:24:19Z","entry_id":3,"field1":"66"},{"created_at":"2013-10-01T09:25:12Z","entry_id":4,"field1":"77"},{"created_at":"2013-10-01T09:28:08Z","entry_id":5,"field1":"88"}]}
Graph of data
- A graphic representation here: https://www.thingspeak.com/channels/7742
Using URLs
- Listing public channels
- User Information URL:
- Retrieving Channel Feeds
- Retrieving the Last Entry in Channel Feed
- To show an existing TalkBack command
- List All TalkBack Commands
- Add a TalkBack Command
- https://api.thingspeak.com/talkbacks/63/commands/api_key=29Z3EVEWFNBYC9NV&command_string=ON
- This one does not work
- Python that works but returns error
- https://api.thingspeak.com/talkbacks/63/commands/api_key=29Z3EVEWFNBYC9NV&command_string=ON
<python> import httplib, urllib
- download from <a href="http://code.google.com/p/psutil/" title="http://code.google.com/p/psutil/">http://code.google.com/p/psutil/</a>
import psutil import time
def doit():
cpu_pc = psutil.cpu_percent() mem_avail_mb = psutil.avail_phymem()/1000000 print cpu_pc print mem_avail_mb params = urllib.urlencode({'api_key':'29Z3EVEWFNBYC9NV','command_string': 'LED_ON','position': 20}) headers = {"Content-type": "application/x-www-form-urlencoded","Accept": "text/plain"} conn = httplib.HTTPConnection("api.thingspeak.com:80") conn.request("POST", "/talkbacks/63/commands", params, headers) response = conn.getresponse() print response.status, response.reason data = response.read() conn.close()
- sleep for 16 seconds (api limit of 15 secs)
if __name__ == "__main__":
while True: doit() time.sleep(16)
</python>
- Update a TalkBack Command
- List All TalkBack Commands
- Execute the Next TalkBack Command
References
<references/>