Datasheet
Usage
To demonstrate the usage of the PCF8523 module you can connect to your board's serial REPL to see the output while
saving our example sketch to main.py
Next connect to the board's serial REPL so you are at the CircuitPython >>> prompt.
Then save this script to main.py (back up or remove whatever was there before)
Setting the time
The first time you run the program, you'll need to set the time
import busio
import adafruit_pcf8523
import time
import board
myI2C = busio.I2C(board.SCL, board.SDA)
rtc = adafruit_pcf8523.PCF8523(myI2C)
days = ("Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday")
if False: # change to True if you want to write the time!
# year, mon, date, hour, min, sec, wday, yday, isdst
t = time.struct_time((2017, 10, 29, 15, 14, 15, 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
print("Setting time to:", t) # uncomment for debugging
rtc.datetime = t
print()
while True:
t = rtc.datetime
#print(t) # uncomment for debugging
print("The date is %s %d/%d/%d" % (days[t.tm_wday], t.tm_mday, t.tm_mon, t.tm_year))
print("The time is %d:%02d:%02d" % (t.tm_hour, t.tm_min, t.tm_sec))
time.sleep(1) # wait a second
© Adafruit Industries https://learn.adafruit.com/adafruit-adalogger-featherwing Page 19 of 36