Chat freely about anything...

User avatar
By Vicky Arora
#45897 I just started learning esp8266 and in my first project I am successfully able to send data to thinkspeak.com using esp8266 calling the following function:

Code: Select alluploadData() {
String apiKey = "ESDS8678890SDDS";
String myData = "45.5"; // example of data to send
if (espClient.connect(server,80)) {
String postStr = apiKey;
postStr +="&field1=";
postStr += String(myData);
postStr += "\r\n\r\n";

espClient.print("POST /update HTTP/1.1\n");
espClient.print("Host: api.thingspeak.com\n");
espClient.print("Connection: close\n");
espClient.print("X-THINGSPEAKAPIKEY: "+apiKey+"\n");
espClient.print("Content-Type: application/x-www-form-urlencoded\n");
espClient.print("Content-Length: ");
espClient.print(postStr.length());
espClient.print("\n\n");
espClient.print(postStr);
Serial.print(postStr);
Serial.print("My Data: ");
Serial.print(myData);
Serial.print("\n");
}
espClient.stop();
}


But I have no idea how to retrieve data from thinkspeak using ESP8266.

// Using XXXXX here as my channel is private
GET https://api.thingspeak.com/channels/XXX ... ?results=2

I think I have to use the above GET string to get the fields data. But I don't know how to create the request string.

Help would be appreciated. Thanks
User avatar
By reaper7
#45899 maybe this not good solution for learning but try this lib:
https://github.com/mathworks/thingspeak-arduino