Retrieve value from ThingSpeak using ESP8266 with Arduino setup
Connect to the server as usual with espClient.connect(). The following request should return a JSON object containing your channel description and the first 2 entries in your feed:

espClient.println("GET /channels/CHANNEL_ID/feeds.json?results=2 HTTP/1.1");
espClient.println("Host: api.thingspeak.com");
espClient.println("Connection: close");
espClient.println();


If it's a private channel, then you must supply your Read API key like this:

espClient.println("GET /channels/CHANNEL_ID/feeds.json?api_key=&lt;your API key&gt;&amp;results=2 HTTP/1.1");


Notice that I use println() and not print() in order to implicitly terminate each request line properly. You should end each line not with \n but with \r\n. You only need to type this yourself if you use print().

To read the returned JSON data:

while (espClient.available() == 0);  // wait till something comes in; you may want to add a timeout here

unsigned long lastRead = millis();  // keeps track of last time a byte was read
while (millis() - lastRead &lt; 2000) {  // while 2 secs havent passed since a byte was read
  while (espClient.available()) {
    Serial.print(espClient.read());
    lastRead = millis();   // update last time something was read
  }
}
client.stop();  // close socket


To parse the JSON string, you either get a library from GitHub or you parse the string yourself.