I want to retrieve data from thingspeak api, but cannot receive the full data. Every time data gets printed partially. What might be the issue?
void display_output(){
Serial.println(esp.readString());
}
void setup() {
Serial.begin(9600);
esp.begin(9600);
esp.println("AT");
delay(10);
display_output();
Serial.println("Connecting to Wifi...");
//connect using ssid and passwd
esp.println("AT+CWJAP=\""+ssid+"\",\""+password+"\"");
delay(6000);
display_output();
}
void loop() {
//open tcp connecti
esp.println("AT+CIPSTART=\"TCP\",\""+host+"\","+port);
delay(20);
display_output();
//send our req length
esp.println("AT+CIPSEND=122");
delay(10);
// esp.println(len);
display_output();
//send out http request
esp.println("GET /channels/1917720/fields/1/last.txt?api_key=ZEPPAQY45HLH3280 HTTP/1.1");
delay(10);
esp.println("Host: api.thingspeak.com");
delay(10);
esp.println("Connection: close");
delay(10);
esp.println();
delay(2000);
//wait for response from the server
while(esp.available() == 0){
delay(5);
}
display_output();
//close tcp connection
esp.println("AT+CIPCLOSE=0");
delay(15000);
}
This is the code which I'm trying.
void display_output(){
while(esp.available())
Serial.println(esp.readString());
}
This code solved the issue
This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.
