2021-05-18 10:18:41 +00:00
|
|
|
from pimoroni_i2c import PimoroniI2C
|
2021-05-10 10:23:27 +00:00
|
|
|
from breakout_rtc import BreakoutRTC
|
2021-05-17 13:50:49 +00:00
|
|
|
import time
|
2021-05-10 10:23:27 +00:00
|
|
|
|
2021-05-18 10:18:41 +00:00
|
|
|
PINS_BREAKOUT_GARDEN = {"sda": 4, "scl": 5} # i2c pins 4, 5 for Breakout Garden
|
|
|
|
PINS_PICO_EXPLORER = {"sda": 20, "scl": 21} # Default i2c pins for Pico Explorer
|
|
|
|
|
|
|
|
i2c = PimoroniI2C(**PINS_BREAKOUT_GARDEN)
|
|
|
|
rtc = BreakoutRTC(i2c)
|
2021-05-10 10:23:27 +00:00
|
|
|
|
|
|
|
if rtc.is_12_hour():
|
|
|
|
rtc.set_24_hour()
|
|
|
|
|
|
|
|
rtc.enable_periodic_update_interrupt(True)
|
|
|
|
|
|
|
|
while True:
|
|
|
|
if rtc.read_periodic_update_interrupt_flag():
|
|
|
|
rtc.clear_periodic_update_interrupt_flag()
|
|
|
|
|
|
|
|
if rtc.update_time():
|
2021-05-17 13:50:49 +00:00
|
|
|
rtc_date = rtc.string_date()
|
|
|
|
rtc_time = rtc.string_time()
|
|
|
|
print("Date: ", rtc_date, ", Time: ", rtc_time, sep="")
|
|
|
|
|
|
|
|
time.sleep(0.1)
|