url+= key;
url+= "&dateutc=now&action=updateraw";
//Nowlet'saddinthedatathatwe'vecollectedfromou
rsensors
//Startwithraininlasthour/day
url+= "&rainin=";
url+= rainLastHour;
url+= "&dailyrainin=";
url+= rainLastDay;
//Nextlet'sdowind
url+= "&winddir=";
url+= windDir;
url+= "&windspeedmph=";
url+= windSpeed;
//Nowfortemperature,pressureandhumidity.
ur
l+= "&tempf=";
url+= bme.readTempF();
url+= "&humidity=";
url+= bme.readFloatHumidity();
url+= "&baromin=";
float baromin= 0.0002953 * bme.readFloatPressure();
url+= baromin;
//ConnnecttoWeatherUnderground.Iftheconnectionfail
s,returnfrom
//loopandstartoveragain.
if (!client.connect(host,httpPort))
{
Serial.println("Connectionfailed");
return;
}
else
{
Serial.println("Connectionsucceeded");
}
//IssuetheGETcommandtoWeatherUndergroundtopo
stth
edatawe've
//collected.
client.print(String("GET")+ url+"HTTP/1.1\r\n" +
"Host:" + host+ "\r\n" +
"Connection:close\r\n\r\n");
//GiveWeatherUndergroundfivesecondstoreply.
unsigned long timeout= millis();
while (client.available()== 0)
{
if (millis() timeout> 5000)
{
Serial.println(">>>ClientTimeout!");
client.stop();
return;
}
}
//ReadtheresponsefromWeatherUndergroundandprinti
ttotheconsole.
w
hile(client.available())
{
String line= client.readStringUntil('\r');
Serial.print(line);
Page 1
of 20