@ -46,7 +46,7 @@ WiFiUDP ntpUDP;
HTTPClient http ;
NTPClient timeClient ( ntpUDP , " pi.lan " , 0 , 60000 ) ; //use internal ntp server, update every 10 minutes, taking in to account the 9 seconds it takes to update the screen for the current time
//NTPClient timeClient(ntpUDP, "au.pool.ntp.org", 0, 60000); //use in ternal ntp server, update every 10 minutes
//NTPClient timeClient(ntpUDP, "au.pool.ntp.org", 0, 60000); //use ex ternal ntp server, update every 10 minutes
// defined in "credentials.h"
const char * ssid = ssid_name ; // The SSID (name) of your Wi-Fi network
@ -250,72 +250,67 @@ void printDateTime(int update_epd)
void weatherUpdate ( void ) {
char buf [ 64 ] ;
const size_t capacity = 4 * JSON_OBJECT_SIZE ( 3 ) + JSON_OBJECT_SIZE ( 4 ) + 150 ;
DynamicJsonBuffer jsonBuffer ( capacity ) ;
DynamicJsonDocument jsonBuffer ( capacity ) ;
http . begin ( wfclient , ds_url ) ;
int httpCode = http . GET ( ) ;
if ( httpCode > 0 ) {
JsonObject & root = jsonBuffer . parseObject ( http . getString ( ) ) ;
if ( ! root . success ( ) ) {
Serial . print ( F ( " parseObject() failed: " ) ) ;
auto error = deserializeJson ( jsonBuffer , http . getString ( ) ) ;
if ( error ) {
Serial . print ( " Failed to parse json " ) ;
return ;
}
}
http . end ( ) ;
JsonObject & today = root [ " today " ] ;
const char * today_day = today [ " day " ] ; // "Wednesday"
const char * today_icon = today [ " icon " ] ; // "sunny.jpg"
const char * today_max = today [ " max " ] ; // "27"
JsonObject & tomorrow = root [ " tomorrow " ] ;
const char * tomorrow_day = tomorrow [ " day " ] ; // "Thursday"
const char * tomorrow_icon = tomorrow [ " icon " ] ; // "sunny.jpg"
const char * tomorrow_max = tomorrow [ " max " ] ; // "31"
const char * today_day = jsonBuffer [ " today " ] [ " day " ] ; // "Wednesday"
const char * today_icon = jsonBuffer [ " today " ] [ " icon " ] ; // "sunny.jpg"
const char * today_max = jsonBuffer [ " today " ] [ " max " ] ; // "27"
const char * tomorrow_day = jsonBuffer [ " tomorrow " ] [ " day " ] ; // "Thursday"
const char * tomorrow_icon = jsonBuffer [ " tomorrow " ] [ " icon " ] ; // "sunny.jpg"
const char * tomorrow_max = jsonBuffer [ " tomorrow " ] [ " max " ] ; // "31"
const char * day_after_day = jsonBuffer [ " day_after " ] [ " day " ] ; // "Friday"
const char * day_after_icon = jsonBuffer [ " day_after " ] [ " icon " ] ; // "pcloud.jpg"
const char * day_after_max = jsonBuffer [ " day_after " ] [ " max " ] ; // "33"
current_outside = jsonBuffer [ " current " ] [ " outside " ] ;
current_bedroom = jsonBuffer [ " current " ] [ " bedroom " ] ;
current_lounge = jsonBuffer [ " current " ] [ " lounge " ] ;
JsonObject & day_after = root [ " day_after " ] ;
const char * day_after_day = day_after [ " day " ] ; // "Friday"
const char * day_after_icon = day_after [ " icon " ] ; // "pcloud.jpg"
const char * day_after_max = day_after [ " max " ] ; // "33"
JsonObject & current = root [ " current " ] ;
current_outside = current [ " outside " ] ;
current_bedroom = current [ " bedroom " ] ;
current_lounge = current [ " lounge " ] ;
Serial . println ( " Updating EPD with weather " ) ;
epd_set_en_font ( ASCII64 ) ;
//Today
epd_disp_bitmap ( today_icon , 0 , 290 ) ;
epd_disp_string ( today_day , 0 , 536 ) ;
epd_disp_string ( today_max , 75 , 460 ) ;
//Tomorrow
epd_disp_bitmap ( tomorrow_icon , 267 , 290 ) ;
epd_disp_string ( tomorrow_day , 260 , 536 ) ;
epd_disp_string ( tomorrow_max , 352 , 460 ) ;
//Day After
epd_disp_bitmap ( day_after_icon , 533 , 290 ) ;
epd_disp_string ( day_after_day , 533 , 536 ) ;
epd_disp_string ( day_after_max , 615 , 460 ) ;
Serial . println ( " Adding Temps " ) ;
sprintf ( buf , " E: %s I: %s " ,
current_outside ,
current_lounge ) ;
current_outside ,
current_lounge ) ;
Serial . println ( buf ) ;
epd_disp_string ( buf , 500 , 225 ) ;
} else {
Serial . print ( " Error on HTTP Request: " ) ;
Serial . println ( httpCode ) ;
}
}
void loop ( ) {