You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This is a continuation of #89 which was closed after reflashing the board seemed to fix. In case anyone else experiences this quite edge case error, this may help resolve as I believe reflashing was a coincidence given the probable cause.
I experienced this error after the board was on the bench for a few months while I replaced my shed that hosted the weather station.
The error was happening in enviro/init.py in this section, specifically the rtc().datetime() line:
# intialise the pcf85063a real time clock chip
rtc = PCF85063A(i2c)
i2c.writeto_mem(0x51, 0x00, b'\x00') # ensure rtc is running (this should be default?)
rtc.enable_timer_interrupt(False)
t = rtc.datetime()
# BUG ERRNO 22, EINVAL, when date read from RTC is invalid for the pico's RTC.
RTC().datetime((t[0], t[1], t[2], t[6], t[3], t[4], t[5], 0)) # synch PR2040 rtc too
I can see this was noted in a previous bug fix run in the comment added by @ZodiusInfuser
Printing the tuple obtained from the RTC showed what appeared to be a value of 25 in the month field t[1] if I have the RTC output correct.
(1907, 25, 25, 18, 14, 41, 6)
some minutes later
(1907, 25, 25, 18, 26, 30, 6)
As I was sat on an uncomfortable toolbox in a shed with a dying laptop battery, I simply placed this hack in to get me over the error and into the time sync code that would set the RTC correctly.
rtc = PCF85063A(i2c)
i2c.writeto_mem(0x51, 0x00, b'\x00') # ensure rtc is running (this should be default?)
rtc.enable_timer_interrupt(False)
t = rtc.datetime()
print(t)
month = t[1]
if month > 12:
month = 12
print(month)
# BUG ERRNO 22, EINVAL, when date read from RTC is invalid for the pico's RTC.
RTC().datetime((t[0], month, t[2], t[6], t[3], t[4], t[5], 0)) # synch PR2040 rtc too
This gave the expected output and allowed the code to progress and I suggest someone dropping something similar in to unlock themselves if it happens in the future. You should be able to return the code to the original lines once the time has sync'd from NTP and back to RTC as it weirdly doesn't provide the wrong month once the RTC is set to a more correct time (not Edwardian).
It is probably worth writing some error handling code to deal with each tuple element properly as a first step, which I may add here and PR in. But it is also probably that this is being caused by the Pimoroni RTC driver or even further upstream, which would warrant some investigation for any other RTC users on Pimoroni firmware @Gadgetoid ? Or otherwise please correct me on the expected format of the output for PCF85063A(i2c).datetime() output.
The text was updated successfully, but these errors were encountered:
This is a continuation of #89 which was closed after reflashing the board seemed to fix. In case anyone else experiences this quite edge case error, this may help resolve as I believe reflashing was a coincidence given the probable cause.
I experienced this error after the board was on the bench for a few months while I replaced my shed that hosted the weather station.
The error was happening in enviro/init.py in this section, specifically the rtc().datetime() line:
I can see this was noted in a previous bug fix run in the comment added by @ZodiusInfuser
Printing the tuple obtained from the RTC showed what appeared to be a value of 25 in the month field t[1] if I have the RTC output correct.
As I was sat on an uncomfortable toolbox in a shed with a dying laptop battery, I simply placed this hack in to get me over the error and into the time sync code that would set the RTC correctly.
This gave the expected output and allowed the code to progress and I suggest someone dropping something similar in to unlock themselves if it happens in the future. You should be able to return the code to the original lines once the time has sync'd from NTP and back to RTC as it weirdly doesn't provide the wrong month once the RTC is set to a more correct time (not Edwardian).
It is probably worth writing some error handling code to deal with each tuple element properly as a first step, which I may add here and PR in. But it is also probably that this is being caused by the Pimoroni RTC driver or even further upstream, which would warrant some investigation for any other RTC users on Pimoroni firmware @Gadgetoid ? Or otherwise please correct me on the expected format of the output for PCF85063A(i2c).datetime() output.
The text was updated successfully, but these errors were encountered: