-
Notifications
You must be signed in to change notification settings - Fork 1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Raspberry Pi Pico RTC is not synchronised by Thonny (code to fix provided) #1592
Comments
Thank you for this thorough report and suggestions! I could incorporate this change into Thonny, but I don't see why the same functionality can't be included in Pico's firmware via I'll wait for Damien's response at micropython/micropython#6831 and then I'll decide how to solve this situation. |
The work-around will be in Thonny 3.3.4 |
So why is there an RTC on the Pico? Do I still need to use an external RTC like DS3231 with a Pico to make time survive power interrupts? The Pico SDK docs don't have any more details about this either: https://raspberrypi.github.io/pico-sdk-doxygen/group__hardware__rtc.html#details Someone in this thread mentions:
Would also explain why waveshare created a pico rtc based on ds3231: https://www.waveshare.com/wiki/Pico-RTC-DS3231 So DS3231, or equivalent, seems necessary for a good clock but any suggestions are welcome. |
@thijstriemstra, I guess RTC is for keeping time while Pico has power. Regarding your other questions, I recommend asking around in either RPi forum or MicroPython forum (http://forum.micropython.org/) |
When using a Raspberry Pi Pico with Thonny the Pico RTC is not synchronised with that of the host computer . . . this leads to a variety of issues, from file dates and times being incorrect to the utime library generating incorrect time.
All that is required to update the RD2040 RTC is the following MicroPython code, please can this be incorporated into Thonny.
A working example of the Python/MicroPython code which updates the Pico RD2040 RTC is provided below.
The above code is designed to be executed on a host computer (Windows, Mac or Linux) and will automagically find a connected Pico and then synchronise its date and time.
No MicroPython code needs be added or running on the Pico for this to work, but Thonny can not be running on the host computer (it blocks the USB serial port) whilst the above script does it's magic
It works by injecting a small MicroPython script, which it modifies on the fly with the host computers UTC, into the Pico over the USB serial link using the RAW REPL functionality of MicroPython.
NOTE: If code is running on the Pico, the synchronisation process will interrupt it. The code running on the Pico board can be restarted using Thonny and the updated RTC will remain, provided the Pico has not been disconnected from power (effectively reseting it). If the code running was automatically started (in main.py), it will be automatically restarted again once the data and time have been synchronised. If the Pico is reset, or disconnected from power, it will need to re-sync with the host computer again to have an accurate RTC (by default, at startup, the MicroPython interpreter running on the Pico initialises the Pico system clock to 1609459201 - Thursday, 1st January 2021 00:00:01).
The text was updated successfully, but these errors were encountered: