ePaper Weather Station display wrong date

Please tell us which board you are using.
For CircuitPython issues, ask in the Adafruit CircuitPython forum.

Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.
User avatar
powershift
 
Posts: 36
Joined: Sat Sep 13, 2014 9:50 am

ePaper Weather Station display wrong date

Post by powershift »

Hi,

I decide to update my ePaper calendar today with the weather station tutorial. The compile worked and upload ok. However, the display date are wrong. Now it shows some future date of Year 2156 Jan 26... I tried to find where the date info came from in the code and I think in void displayHeading(OpenWeatherMapCurrentData &owcdata), the datetime string is processed here: strftime(datestr,80,"%a, %b %d",timeinfo); But I don't understand why it's getting the wrong year, month and date?

It seems even after reset and try to read data again, it is still consistently showing wrong date... Any hint or help would be appreciated.

Thanks

User avatar
adafruit_support_mike
 
Posts: 67485
Joined: Thu Feb 11, 2010 2:51 pm

Re: ePaper Weather Station display wrong date

Post by adafruit_support_mike »

It sounds like the timestamp from the weather channel may have changed.

What's the raw data you get from there (the contents of owcdata)?

User avatar
powershift
 
Posts: 36
Joined: Sat Sep 13, 2014 9:50 am

Re: ePaper Weather Station display wrong date

Post by powershift »

I think here are the relevant data:

data retrieved:
{"coord":{"lon":-87.96,"lat":14.25},"weather":[{"id":804,"main":"Clouds","description":"overcast clouds","icon":"04n"}],"base":"model","main":{"temp":62.62,"feels_like":60.6,"temp_min":62.62,"temp_max":62.62,"pressure":1015,"humidity":87,"sea_level":1015,"grnd_level":879},"wind":{"speed":8.55,"deg":4},"clouds":{"all":91},"dt":1576980795,"sys":{"country":"HN","sunrise":1576930282,"sunset":1576970898},"timezone":-21600,"id":3602137,"name":"San Jose","cod":200}

….

captured 2321 bytes
data retrieved:
{"cod":"200","message":0,"cnt":6,"list":[{"dt":1576983600,"main":{"temp":62.62,"feels_like":60.6,"temp_min":62.62,"temp_max":62.62,"pressure":1015,"sea_level":1015,"grnd_level":879,"humidity":87,"temp_kf":0},"weather":[{"id":804,"main":"Clouds","description":"overcast clouds","icon":"04n"}],"clouds":{"all":91},"wind":{"speed":8.55,"deg":4},"sys":{"pod":"n"},"dt_txt":"2019-12-22 03:00:00"},{"dt":1576994400,"main":{"temp":61.99,"feels_like":59.94,"temp_min":61.99,"temp_max":61.99,"pressure":1014,"sea_level":1014,"grnd_level":877,"humidity":86,"temp_kf":0},"weather":[{"id":803,"main":"Clouds","description":"broken clouds","icon":"04n"}],"clouds":{"all":55},"wind":{"speed":8.01,"deg":1},"sys":{"pod":"n"},"dt_txt":"2019-12-22 06:00:00"},{"dt":1577005200,"main":{"temp":60.82,"feels_like":58.59,"temp_min":60.82,"temp_max":60.82,"pressure":1013,"sea_level":1013,"grnd_level":877,"humidity":87,"temp_kf":0},"weather":[{"id":803,"main":"Clouds","description":"broken clouds","icon":"04n"}],"clouds":{"all":64},"wind":{"speed":7.85,"deg":8},"sys":{"pod":"n"},"dt_txt":"2019-12-22 09:00:00"},{"dt":1577016000,"main":{"temp":60.44,"feels_like":58.19,"temp_min":60.44,"temp_max":60.44,"pressure":1015,"sea_level":1015,"grnd_level":878,"humidity":86,"temp_kf":0},"weather":[{"id":803,"main":"Clouds","description":"broken clouds","icon":"04n"}],"clouds":{"all":77},"wind":{"speed":7.45,"deg":6},"sys":{"pod":"n"},"dt_txt":"2019-12-22 12:00:00"},{"dt":1577026800,"main":{"temp":69.62,"feels_like":67.53,"temp_min":69.62,"temp_max":69.62,"pressure":1016,"sea_level":1016,"grnd_level":879,"humidity":66,"temp_kf":0},"weather":[{"id":802,"main":"Clouds","description":"scattered clouds","icon":"03d"}],"clouds":{"all":45},"wind":{"speed":8.1,"deg":11},"sys":{"pod":"d"},"dt_txt":"2019-12-22 15:00:00"},{"dt":1577037600,"main":{"temp":77.68,"feels_like":76.48,"temp_min":77.68,"temp_max":77.68,"pressure":1013,"sea_level":1013,"grnd_level":878,"humidity":49,"temp_kf":0},"weather":[{"id":802,"main":"Clouds","description":"scattered clouds","icon":"03d"}],"clouds":{"all":39},"wind":{"speed":6.06,"deg":13},"sys":{"pod":"d"},"dt_txt":"2019-12-22 18:00:00"}],"city":{"id":3602137,"name":"San Jose","coord":{"lat":14.2466,"lon":-87.9604},"country":"HN","population":1463,"timezone":-21600,"sunrise":1576930282,"sunset":1576970899}}



Data seems to be correct but timezone looks suspicious:

"timezone":-21600

Not sure why this is -6hr instead of -8hr (PST)...

Thanks,

Leonard
Attachments
IMG_2552-2.jpeg
IMG_2552-2.jpeg (45.01 KiB) Viewed 643 times

User avatar
adafruit_support_mike
 
Posts: 67485
Joined: Thu Feb 11, 2010 2:51 pm

Re: ePaper Weather Station display wrong date

Post by adafruit_support_mike »

Hmm.. all the timestamps there look good.

Find this line of code, around line 374 of the adafruit_epd_weather.ino sketch:

Code: Select all

  gfx.print(datestr);
and change it to this:

Code: Select all

  gfx.print(local);
That should show the raw value the code is using for the timestamp adjusted for the current timezone.

User avatar
powershift
 
Posts: 36
Joined: Sat Sep 13, 2014 9:50 am

Re: ePaper Weather Station display wrong date

Post by powershift »

I can't compile after the change as line 374 cause an error of "call of overloaded 'print(time_t&) is ambiguous.

User avatar
powershift
 
Posts: 36
Joined: Sat Sep 13, 2014 9:50 am

Re: ePaper Weather Station display wrong date

Post by powershift »

I noticed on line 367 that local is the sum of owcdata.observationTime and owcdata.timezone in time_t; so I made a char tbuff[80] and added:

sprintf(tbuff, "%d", owcdata.observationTime);
Serial.print(tbuff);
Serial.print(" == ");
sprintf(tbuff, "%d", owcdata.timezone);
Serial.print(tbuff);
Serial.println();

the output is:

1578106438 == -21600

where current unix time from my Linux machine with command line $date +%s is:
1578106528 so it's close enough and the time stamp from owc should be correct.

User avatar
powershift
 
Posts: 36
Joined: Sat Sep 13, 2014 9:50 am

Re: ePaper Weather Station display wrong date

Post by powershift »

I changed the debug function to right after line 370 as:

sprintf(tbuff, "%d", timeinfo);
Serial.print(tbuff);
strftime(datestr,80,"%a, %b %d %Y",timeinfo);
Serial.print(" == ");
sprintf(tbuff, "%d", datestr);
Serial.print(tbuff);
Serial.println();

and the output become:

536876792 == 537063232

clearly, this is way in future. and convert it back in Linux become Feb 10, 2156...

So, looks like line 369:

struct tm *timeinfo = gmtime(&local);

somehow incorrectly convert the (right) time into future.

So, I check the local value and it is still correct. Thus the problem seems to point to gmtime conversion...

User avatar
adafruit_support_mike
 
Posts: 67485
Joined: Thu Feb 11, 2010 2:51 pm

Re: ePaper Weather Station display wrong date

Post by adafruit_support_mike »

Hmm.. those values put the timestamp back around 1987.

The previous timestamps (1578106438) were 10-digit numbers. The ones above are (536876792) 9-digits long, which moves them back closer to the 1970 epoch date.

Something does seem to be going haywire in the gmtime() function though.

What kind of microcontroller are you using?

User avatar
powershift
 
Posts: 36
Joined: Sat Sep 13, 2014 9:50 am

Re: ePaper Weather Station display wrong date

Post by powershift »

The controller is 1 of the Adafruit Metro M4 Express AirLift (WiFi) - Lite (PID4000), purchased Aug 26, 2019. The only thing it had updated was the WifiNina firmware. As stated, this one had been running the calendar app for few month and I feel it's too "static" (change once per day) and there are a few other 7-Seg clock (upgraded to Esp32 Hazzah) made with 1.2" display (PID 1266, etc).

My idea was to try out the weather app first, then mix the code to integrate the calendar app and maybe add other display (I also have a Adafruit quote epaper display as well) info so that content will rotate every few minutes. However, I got stuck in try out the weather app demo code.

Alternatively, I can try to add the NTP function and use that time instead as a short term patch... but find out what cause the wrong date seems the right thing to do at least.

User avatar
adafruit_support_mike
 
Posts: 67485
Joined: Thu Feb 11, 2010 2:51 pm

Re: ePaper Weather Station display wrong date

Post by adafruit_support_mike »

It sounds like there may be a glitch in the time.h library for the M4.. we'll have to check that out.

User avatar
TWDM
 
Posts: 53
Joined: Sat Sep 05, 2015 9:07 am

Re: ePaper Weather Station display wrong date

Post by TWDM »

Same issue here, 2156 and wrong time. Weather info looks correct. I will watch for a resolution.

Thanks

User avatar
rhweatherley
 
Posts: 2
Joined: Mon Feb 10, 2020 9:49 pm

Re: ePaper Weather Station display wrong date

Post by rhweatherley »

-Same issue here. Purchased this week (Feb 15, 2020), All weather info looks good, City is correct. Even "timezone" from OWM appears correct at -18000 for E.S.T, (-5). But date shows Sun March 28, 2156. I will attempt to resolve, but, hopefully a correction to the software will be forthcoming.

User avatar
powershift
 
Posts: 36
Joined: Sat Sep 13, 2014 9:50 am

Re: ePaper Weather Station display wrong date

Post by powershift »

FYI - I cheated by adding NTP time instead as I am not proficient to debug library.

However, due to new project, I may have to redeploy this setup as message sign for rotating WiFi password.

User avatar
56647
 
Posts: 2
Joined: Mon Jan 06, 2020 10:55 am

Re: ePaper Weather Station display wrong date

Post by 56647 »

Hi!
I'm having the same issue with the wrong display date; in my case, the date displays as Thur, Apr 08 2156. Has a resolution to this issue been posted? If so, I'd greatly appreciate a shout out on where to look.
Thanks much!

User avatar
rhweatherley
 
Posts: 2
Joined: Mon Feb 10, 2020 9:49 pm

Re: ePaper Weather Station display wrong date

Post by rhweatherley »

Came up with the following temporary solution. This should be considered temporary until Adafruit supplies correct coding, still waiting! The lines pertain to the coding currently available with the weather instructions etc, on the Adafruit's website namely: adafruit_epd_weather.ino.

Here goes:
Change #1, Line 276:
Original:
time_t local = owcdata.observationTime + owcdata.timezone;
Change to:
time_t local = owcdata.observationTime + owcdata.timezone - 4294967000;

Change #2, Line 299: (//day)
Original:
time_t local = owfdata.observationTime + owcdata.timezone;
Change to:
time_t local = owfdata.observationTime + owcdata.timezone - 20000;

Change #3, Line 366: // date string
Original:
time_t local = owcdata.observationTime + owcdata.timezone;
Change to:
time_t local = (owcdata.observationTime + owcdata.timezone - 4294967000);

Change #4, Line 506: (sunrise)
Original:
time_t local = owcdata.sunrise + owcdata.timezone + 30;
Change to:
time_t local = owcdata.sunrise + owcdata.timezone + 30 - 23340;

Change #5, Line 514: (sunset)
Original:
time_t local = owcdata.sunrise + owcdata.timezone + 30;
Change to:
time_t local = owcdata.sunrise + owcdata.timezone + 30 - 23340;

I have also added the following changes to add an autoreset function
At the start, include the following library:
#include <Adafruit_SleepyDog.h>

Comment out the following original code at lines 590 & 591:
{
displayError("Can not get weather data, press reset to
restart");
}

I have also added the following code beginning at line 590.
This will provide for an “AutoReset” function:
{
// displayError("Can not get weather data, press reset to restart.");
// while(1);
displayError("Can't get weather info,... RESETTING in 5 secs.");
int countdownMS = Watchdog.enable(6000);
Serial.print(countdownMS, DEC), Serial.print(" milliseconds");
Serial.println(" --- The End ---- ");
delay(countdownMS+2000);
while(1);
}

Locked
Please be positive and constructive with your questions and comments.

Return to “Metro, Metro Express, and Grand Central Boards”