I am trying to get the weather from Openweathermap using the Arduinojson library v6.9.1. It is working when using a hardcoded json string but when getting it from a http GET I receive a "deserialization Error. Failed with code IncompleteInput" message. All the HTTP operations return clear of error as far I can see, I don't know what I am doing wrong. Any help welcome, learning, learning :-\
I attach the ino file, too big to fit the 9000 charaters limits
Thanks
static String convResult[4]; // Array used in printDigits() function
So, why does this need to be global?
// Listening for incoming clients
WiFiClient client = wServer.available();
if (client) {
Serial.println("new client");
// Set LED connection status
WiFiDrv::analogWrite(GREEN_LED, 0);
WiFiDrv::analogWrite(BLUE_LED, 200);
// Make HTTP request
// makehttpRequest();
Serial.println(F("Starting HTTP connection"));
// close any connection before send a new request to allow client make connection to server
client.stop();
client.setTimeout(1000);
if (!client.connect(server, 80)) {
This piss-poorly indented code makes NO sense. Are you trying to be a server or a client?
If there is a client trying to connect, stop it. That makes no sense.
The Arduino doesn't appear to do anything except act as a go-between between the browser and the weather underground server. That's a silly thing to make it do. Just point your browser at the weather underground site.
Since you failed to show the data you get from the server, you can't expect us to tell you what is wrong.
Thanks for your reply (even if the "piss-poorly indented code" was optionnal). The client.stop(); was sometime I forgot to remove when moving things around but isn't in the version I am testing.
static String convResult[4] because as far I read C++ does not allow passing an array to a function, but a function can modify it. Your advice about another way doing it is welcome.
It is both a client and a server: Client when getting the data from the openweather site and Server when displaying the result to the browser connecting the Arduino. Yes I can directly connect my laptop to openweathermap but that's not the point, the Arduino will integrates local sensors data and relay to other systems, now I am trying to understand json, and Web stuff on an Arduino (as well as C++ obviously).
I stopped programing 35 years ago, C++ was even not invented, I worked on an HP-85, Bull, I did assembly, gwbasic, Cobol and Visual Foxpro. goto was the King and object-Programing a curosity. I installed the first Novell servers to the CERN with hudge 70Mbs HDDs before Tim Berners-Lee invented the World Wide Web. Please respect the dinosaur, I may poorly piss C++ but I openned the way to many.