-->
Page 3 of 8

Re: WiFiClient example

PostPosted: Wed Aug 19, 2015 12:08 pm
by lajolo
That seems to work fine, thanks!

And I have left '\r' here:

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

Re: WiFiClient example

PostPosted: Wed Aug 19, 2015 12:20 pm
by torntrousers
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());
}

Re: WiFiClient example

PostPosted: Wed Aug 19, 2015 2:10 pm
by lajolo
Thanks.
I tried it, but it seems to print garbage (only numbers, nothing related to the html file that it should download.

Re: WiFiClient example

PostPosted: Wed Aug 19, 2015 2:22 pm
by torntrousers
The perils of just typing code on the fly...try
Code: Select allSerial.write(client.read());