Thingspeak and mbed | ThingSpeak Projects | Forum

Avatar

Please consider registering
Guest

sp_LogInOut Log In sp_Registration Register

Register | Lost password?
Advanced Search

— Forum Scope —






— Match —





— Forum Options —





Minimum search word length is 3 characters - maximum search word length is 84 characters

sp_Feed sp_TopicIcon
Thingspeak and mbed
No permission to create posts
March 10, 2014
4:42 am
Avatar
Mircea3M

Silver
Members
Forum Posts: 7
Member Since:
March 5, 2014
sp_UserOfflineSmall Offline

Dear all,

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.

Thanks,
Mircea.

March 10, 2014
5:20 am
Avatar
Mircea3M

Silver
Members
Forum Posts: 7
Member Since:
March 5, 2014
sp_UserOfflineSmall Offline

Dear all,

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):
{
"created_at": "2014-02-26T21:27:21Z",
"entry_id": 144,
"field1": "28.5",
}

Nevertheless, when I was reading the API documentation I was thinking ... what in the world is this...but actually is really simple.

Forum Timezone: America/New_York

Most Users Ever Online: 166

Currently Online:
24 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:

swatiiot, kalyanigaware16@gmail.com, Romi, Drakan01, majidkhan7, atharvganla

Moderators: cstapels: 460

Administrators: Hans: 405, lee: 457