uploadData() {
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