I am using an mbed NXP LPC1768 to upload data to a thingspeak channel and everything works fine, but if I try to read data from a channel I got into problems, maybe someone can help...since I don't have to much background on the subject.
this is how I build the data to send over http to thingspeak, where:
- thingSpeakUrl is the following string: "http://api.thingspeak.com/update"
- thingSpeakKey is the Thingspeak write API key of my channel
- test_data is a random data of float type...(let's say temperature)
sprintf( urlBuffer, "%s?key=%s&field1=%f", thingSpeakUrl, thingSpeakKey, test_data);
this is how data is sent to thingspeak
HTTPResult res = http.get(urlBuffer, str, 128);
The problem is that i don't know how to read data back or where I can find or extract it.
- thingSpeakUrl_read is the following string: "https://api.thingspeak.com/channels/10887/feeds/last"
- thingSpeakKey_read is the Thingspeak read API key of my channel
- read_data is a float type data.
sprintf(url_read_Buffer, "%s?key=%s%f=&field1", thingSpeakUrl_read, thingSpeakKey_read, read_data);
Sorry for the long post.
Please let me know if you have any ideea.
I solved the issue, the problem was the way I was building the request...after reading the API documentation more carefully.
Bellow there is the way it worked:
sprintf(url_read_Buffer, "%s?key=%s", thingSpeakUrl_read, thingSpeakKey_read);
HTTPResult res_2 = http.get(url_read_Buffer, str2,128);
where str2 is a string with a length of 512.
The response comes under the JSON format (a little bit of string processing will deal with data value extraction):
Nevertheless, when I was reading the API documentation I was thinking ... what in the world is this...but actually is really simple.
Most Users Ever Online: 114
Currently Browsing this Page:
Guest Posters: 1
Administrators: Hans, lee