Hi, all,
Time change time again. I was wondering if there is a quick and easy way to set the RTC? (mine's an 8523 on a datalogger shield with a Metro ESP32-S2 running Circuitpython 8.x). It would seem the REPL is a powerful and versatile tool and could do so, but I am having trouble finding anything on it.
I new to Circuitpython, and am working on migrating some of our UNO based instruments onto Metro platforms. It is a pretty steep learning curve from Arcuino/C++ to Circuitpython, but I am making headway, and the ecosystem is still growing. All our instruments are standalone, not connected to any network.
There has to be a better way than unplugging the RTC/shield from the Metro, putting it on an UNO with an RTC set sketch on it, then reinstalling on the Metro!
Thank you for help with my previous questions.
Is there a quick way to set RTC, maybe from REPL? (8523)
Moderators: adafruit_support_bill, adafruit
Please be positive and constructive with your questions and comments.
- electromechpro
- Posts: 23
- Joined: Wed Jan 25, 2023 3:56 pm
- dastels
- Posts: 15658
- Joined: Tue Oct 20, 2015 3:22 pm
Re: Is there a quick way to set RTC, maybe from REPL? (8523)
You should be able to do it in the REPL.
Set the datetime property, from the example:
Dave
Set the datetime property, from the example:
Code: Select all
import time
import board
import adafruit_pcf8523
rtc = adafruit_pcf8523.PCF8523(board.I2C())
t = time.struct_time((2017, 10, 29, 10, 31, 0, 0, -1, -1))
# you must set year, mon, date, hour, min, sec and weekday
# yearday is not supported, isdst can be set but we don't do anything with it at this time
rtc.datetime = t
- electromechpro
- Posts: 23
- Joined: Wed Jan 25, 2023 3:56 pm
Re: Is there a quick way to set RTC, maybe from REPL? (8523)
Thank you for the reply. I had been setting the RTC in Arduino with the following code
//RTC.adjust(DateTime(F(__DATE__), F(__TIME__)));
(uncommenting, downloading, recommenting, download), and was looking for a similar way in Circuitpython. I had tried the more lengthy code from the example but messed something up. I will try the more concise example you gave me in the REPL (I had also not imported 8523 library in the REPL).
//RTC.adjust(DateTime(F(__DATE__), F(__TIME__)));
(uncommenting, downloading, recommenting, download), and was looking for a similar way in Circuitpython. I had tried the more lengthy code from the example but messed something up. I will try the more concise example you gave me in the REPL (I had also not imported 8523 library in the REPL).
Please be positive and constructive with your questions and comments.