Example sketches for the new Arduino IDE for ESP8266

Moderator: igrr

User avatar
By lajolo
#26490 That seems to work fine, thanks!

And I have left '\r' here:

while(client.available()){
String line = client.readStringUntil('\r');
Serial.print(line);
}
User avatar
By torntrousers
#26491
lajolo wrote:That seems to work fine, thanks!

And I have left '\r' here:

while(client.available()){
String line = client.readStringUntil('\r');
Serial.print(line);
}


The readStringUntil('\r') will wait for a timeout if it doesn't find a '\r', I forget how long but i think it was 1 second. Doesn't really matter in that code but for a battery powered sensor that sleeps most of the time and just wakes up briefly to send something that waiting can significantly add to the up time and battery drain so you might want to avoid it. In that code you might as well just do:

Code: Select allwhile(client.available()){
   Serial.print(client.read());
}
User avatar
By lajolo
#26501 Thanks.
I tried it, but it seems to print garbage (only numbers, nothing related to the html file that it should download.