Quantcast
Channel: Raspberry Pi Forums
Viewing all articles
Browse latest Browse all 8082

MicroPython • Re: How to set the right Pi Pico system time? With the use of DS3231?

$
0
0
I have visited the link https://docs.micropython.org/en/latest/ ... e.RTC.html earlier. I have played with it without succes.
I have some questions about what is shown, because I am not yet experienced in this matter.
rtc = machine.RTC() What is the RTC(). Is that the RTC of the (pc) system to which the USB cable is connected to?
and if I remove the USB connector and plug this into a 5V usb adapter and use this rtc = machine.RTC() again, is the RTC() now the Pi Pico?
And is the variable rtc a random chosen name or is it a reserved one?
What is rtc.datetime((2020, 1, 21, 2, 10, 32, 36, 0)) doing? Is it setting something? Is it an example?
I am running main.py with a Pi Pico. There is a DS3231 with the actual time. It has a battery onboard so the actual time is not lost. It is available and the logfile main.py is producing logs indeed the actual time together with the sensor data.
I can not manage it to transfer the actual time from the DS3231 into the Pi Pico ( no idea which code I have to use) directly after power up of the Pi Pico and just before the log file is created, with the result that the creation date of the logfile is the actual date/time and not 31-12-2020 00:00:00. Sometimes I see rtc = urtc.DS3231(i2c) or # Sync the RTC with rtc.datetime(initial_time) and then current_datetime = rtc.datetime()
Sorry, I miss the knowledge for this issue. An example to give me some steps forward is very welcome. Thank you in advance.

Statistics: Posted by user-10 — Sat Apr 26, 2025 8:59 pm



Viewing all articles
Browse latest Browse all 8082

Trending Articles