Main Menu

search

You are here

RTC - Real-time Clock

[last updated: 2022-07-31]
programming code
wall clock/timer project
sprinkler system project
See Links below:
-----

plug
jack
  • PCF8523 Real-time Clock (Adafruit PID: 3295)
    • it can run from 3.3V or 5V power & logic
    • CR1220 3v coin cell battery saves current time even if main power is disconnected
      It appears that the RTC will operate even if the CR1220 is not installed, however I did get some mixed results when first trying it, with some errors of: "RTC is NOT running!"
    • Not a high precision device. It may lose or gain up to 2 seconds a day.
    • Communicates with MCU via I2C, with fixed (not changeable) address 0x68.
    • Has a SQW square-wave output that must be enabled via software
    • There are internal 10K pull-ups to Vcc on the PCF8523 on SDA and SCL lines.
    • Uses JeeLab's RTC library, available on GitHub or in the Arduino Library Manager as RTClib.
      Use "RTClib by Adafruit"
        IDE --> Tools --> Manage Libraries
        type RTClib in search bar
        find RTClib by Adafruit
        click Install
    • In Arduino IDE, Open up Examples->RTClib->pcf8523
      Set Serial monitor to 57600 baud


      Set the RTC's time:

      • There are different ways and places you can do this:
        • To set the RTC time to a specific time, put a line like this in your Arduino code:
            // year, month, day-of-month, hour, min, sec
            rtc.adjust(DateTime(2022, 1, 1, 13, 0, 0));
        • Use this line to set the RTC time to the time that your computer was at when you last compiled the Arduino program
            rtc.adjust(DateTime(F(__DATE__), F(__TIME__)));

    -----------------------------------------------------------------------------------------------------------------------

  • DSS3231 Precision RTC Breakout (Adafruit PID: 3013)
    -------------------------------------

  • Reference Links:
    (link to:) Adafruit tutorial

    (link to:) PCF8523 Mfr page

.

.

.

eof