Close

Code update 1.0

A project log for WiFi Clock

A WiFi clock who also displays temperature & weather if it turns bad !

romaindurocherromaindurocher 11/02/2020 at 02:050 Comments

First code update to fix minor stuff.

First, I add a function to display something in case Wifi connexion were lost. I add a 15s timeout at startup and check it every 5s in main loop.


if(WiFi.status() != WL_CONNECTED){
      whoops();
}

//#################################""
void whoops(){

  alpha4.clear();
  alpha4.writeDisplay();

  while(1){
          
    alpha4.writeDigitAscii(1, 'N');
    alpha4.writeDigitAscii(2, 'C');
    alpha4.writeDisplay();  

  }
}

Second, I changed the OpenWeather API call to their OneCall API (See documentation here ), because the Forecast API I used had only 3h forecast step, which is somewhat not so reliable .. OneCall have 1h step, which is much better for me ! 

(To be clear, when you ask the API, they don't answer the forecast for the next 3h, but the forecast for a predetermined 3h period of time, for exemple 0h to 3h, 3h to 6h, 6h to ... If there are rain for 10 minute during this 3h priod of time, the clock will display "rain" for 3h ...)


Github code is updated, I also add location variables in API call.

Discussions