title: esp8266 getting data from thingspeak by using IPD answer
body: <p>i am new here, if asked before sorry in advance,
  i cannot found a related question.</p>
  
  <p>I edited a code for get the thingspeak channel's data, for using with a led or relay on channel 8 on arduino uno. according to data 1 or 0, the led would be on or off. I am using esp8266.</p>
  
  <p>espSerial.find("+IPD,1:0") block is cannot work as it needed to do.</p>
  
  <pre><code>#include &lt;SoftwareSerial.h&gt;
  SoftwareSerial espSerial(2, 3);   
  #define DEBUG true
  String mySSID = "ssid";
  String myPWD = "pass"; 
  String myAPI = "CV4YEARDB91GTOXM";   // API Key
  String myHOST = "api.thingspeak.com";
  String myPORT = "80";
  String myFIELD = "field1";
  
  void setup()
  {
    pinMode(8,OUTPUT);
    Serial.begin(9600);
    espSerial.begin(115200);
  
    espData("AT+RST", 1000, DEBUG);                     
    espData("AT+CWMODE=1", 1000, DEBUG);                 
    espData("AT+CWJAP=\""+ mySSID +"\",\""+ myPWD +"\"", 1000, DEBUG);   
    delay(1000); }
  
  void loop()
    {
  
      String sendData = "GET /channels/716457/fields/1/last?key=CV4YEARDB91GTOXM";
      espData("AT+CIPMUX=1", 1000, DEBUG);
      espData("AT+CIPSTART=0,\"TCP\",\""+ myHOST +"\","+ myPORT, 1000, DEBUG);
      espData("AT+CIPSEND=0," +String(sendData.length()+4),1000,DEBUG);
      espSerial.find("&gt;");
      espSerial.println(sendData);
  
      espData("AT+CIPCLOSE=0",1000,DEBUG);
      delay(10000);
    }
  
  String espData(String command, const int timeout, boolean debug)
  {
  Serial.print(command);
    Serial.println("     ");
  
    String response = "";
    espSerial.println(command);
    long int time = millis();
    while ( (time + timeout) &gt; millis())
    {
      while (espSerial.available())
      {
        if (espSerial.find("+IPD,1:0")) {
          digitalWrite(8,LOW); }
        if (espSerial.find("+IPD,1:1")) {
          digitalWrite(8,HIGH); }
      }
      }
  
    if (debug)
    {
      Serial.print(response);
    }
    return response;
  }
  </code></pre>