Any help or advice is appreciated, thank you.
Below is the shortened code:
void httpRequest() {
client.stop();
Serial.println("Making request");
int con_val = client.connect(server, 80);
Serial.println(con_val);
if (con_val) {
// GET request
client.println("GET /data/2.5/weather?q="+City+"&units=metric&APPID=" +app_id+" HTTP/1.1");
client.println("Host: api.openweathermap.org");
client.println("User-Agent: ArduinoWiFi");
client.println("Connection: close");
client.println();
unsigned long timeout = millis();
while (client.available() == 0) {
if (millis() - timeout > 5000) {
Serial.println("Client timed out");
client.stop();
return;
}
}
char c = 0;
while (client.available()) {
/* Verify JSON HERE */
}
}
}
else {
Serial.println("Connection failed");
return;
}
}