PCF8523 RTC Module Pinout, I²C Address, Battery Backup and ESP32 Arduino Guide

PCF8523 RTC pinout and ESP32 I2C wiring, fixed 0x68 address, CR1220 backup battery, alarms, drift calibration and Adafruit RTClib Arduino example.

In this esp32.co.uk/ article, we examine the PCF8523 breakout pinout, backup-cell operation, accurate ESP32 connection tables and the Adafruit RTClib setup.

The PCF8523 real-time clock (RTC) gives an ESP32 a battery-backed calendar and seconds counter that continue running after the microcontroller loses power. It uses a 32.768 kHz external quartz crystal, communicates over I²C, and offers an alarm, countdown timers, a configurable clock output and software drift compensation. This hardware-reference guide covers the Adafruit PCF8523 STEMMA QT breakout #5189, the older header-only Adafruit #3295, the underlying chip pinout, an ESP32 pin-to-pin connection table and a complete Arduino IDE example using Adafruit RTClib.

Quick answer: connect 3V3 → VCC/VIN, GND → GND, GPIO21 → SDA and GPIO22 → SCL on a classic ESP32-WROOM DevKit, matching the labels printed on your breakout. The clock uses the fixed 7-bit I²C address 0x68; there are no address-selection solderPriceAliExpress price jumpers. Fit the specified CR1220 backup battery if you need timekeeping after the main supply is removed.

Important: the PCF8523 and DS3231PriceAliExpress price both use 0x68, so two such clocks cannot be independently addressed on one ordinary I²C segment. The PCF8523 is also not a temperature-compensated clock: for better long-term absolute accuracy the DS3231 is typically the stronger choice.

PCF8523 Adafruit 5189 and 3295 RTC breakout labelled pinout VCC GND SDA SCL SQW STEMMA QT CR1220
Adafruit PCF8523 boards use the same VCC/GND/SDA/SCL/SQW functions but differ in connector layout. The STEMMA QT sockets are on product #5189 only.

PCF8523 specifications: what does this RTC actually provide?

FeatureSpecification / consequence
Clock and calendarSeconds, minutes, hours, weekdays, days, months and years
BusI²C; default/fixed 7-bit address 0x68; silicon supports up to 1 MHz Fast-mode Plus with suitable bus hardware
CrystalExternal 32.768 kHz tuning-fork quartz; board supplies this component
AccuracyNot temperature-compensated. Adafruit warns of gains/losses up to roughly 2 seconds/day in typical use; calibration can correct measured rate error
Power supplyPricePCF8523 silicon operates across a wide range; Adafruit breakout can be used at 3.3 V or 5 V logic but match your microcontroller logic
Backup batterySeparate VBAT input; Adafruit carrier accepts non-rechargeable CR1220 coin cell for backup
Backup consumptionVery low power for RTC-only operation; chip typical backup current is about 150 nA under specified conditions
Extra outputSQW / INT1-CLKOUT pin for square wave or interrupt, subject to mode selection
Timers and alarmCalendar alarm plus timer interrupts; useful for low-power data loggers
Offset correctionSigned -64…+63 trim register, with correction modes every 2 hours or every minute
Stock/lifecycleNXP currently lists the PCF8523 as no longer manufactured; Adafruit still lists breakout products

NXP’s product-status listing refers to the chip’s manufacturing status. It does not mean all breakout-board stock has disappeared, but it matters if designing something that must be built and serviced over several years. Verify component availability and consider an actively manufactured RTC before committing to a production PCB.

Adafruit PCF8523 breakout pinout: VCC, GND, SDA, SCL and SQW

Adafruit’s #5189 includes two STEMMA QT / Qwiic connectors, a battery holder and a five-signal through-hole header. The older #3295 is a header-only breakout; its PCB revision may contain an SOIC-8 or HVSON-8 PCF8523. Both have the same functional signals, but the physical left-to-right header order can differ by board side, rotation and revision. Use the actual printed silkscreen as your reference rather than the position of an unverified picture.

Printed breakout signalMeaningESP32 use
VCC (sometimes VIN on artwork)Main clock supply and pull-up logic reference; this Adafruit breakout has no regulator that makes its I²C pins automatically independent of VCCPower from ESP32 3V3
GNDCommon referenceESP32 GND
SDAI²C bidirectional dataClassic ESP32 GPIO21
SCLI²C clockClassic ESP32 GPIO22
SQWClock output / interrupt functionality when enabled; open-drain signallingOptional GPIO input with appropriate 3.3 V pull-up
STEMMA QT pairParallel four-wire bus connectors carrying VCC, GND, SDA and SCLAlternate connection on #5189; not a second independent RTC bus
CR1220 holderBackup supply for timekeepingNot a power bank for the ESP32

The Adafruit design has I²C pull-ups of approximately 10 kΩ to VCC. Running the module from 5 V while directly attaching an unprotected 3.3 V ESP32 would place inappropriate high-voltage levels on the bus. Use 3.3 V for ESP32 wiring. Check other modules on the same bus before adding more pull-up resistors.

PCF8523 chip pinout is not the same as the breakout header

The PCF8523 is sold in several packages. The 8-pin SOIC chip has oscillator pads, a separate main supply and backup supply, a ground pin, I²C data and clock and a multifunction output. You cannot wire a bare PCF8523 in the same way as a labelled Adafruit module without also supplying its quartz crystal and required passive components.

PCF8523 address and I²C scanner results

The normal seven-bit address is 0x68, which is fixed for the off-the-shelf PCF8523. A datasheet may quote 0xD0 for an 8-bit write address and 0xD1 for read. Arduino Wire, RTClib and an I²C scanner use the seven-bit value 0x68 instead.

There is no equivalent of the A0/A1/A2 address solder bridges found on a PCF8574AliExpress price or MCP23017. If you need two fixed-address RTCs, put them on separate microcontroller I²C controllers or separate branches of an I²C multiplexer. A TCA9548A multiplexer is one supported method, although an ordinary logger almost never needs two RTCs.

PCF8523 default fixed I2C address 0x68 versus 8 bit 0xD0 write plus CR1220 battery backup behavior and DS3231 address conflict
The RTC has no address solder jumper. The CR1220 supports timekeeping during power loss but does not power the ESP32.

CR1220 backup battery: what happens when ESP32 power is removed?

The Adafruit breakout contains a dedicated CR1220 holder. The primary 3 V lithium cell supplies the PCF8523 VBAT input when normal VCC falls below the switchover condition and the RTC is configured correctly. CR1220 is not rechargeable. The Adafruit breakout does not function as a coin-cell charger. Do not replace it with an arbitrary rechargeable chemistry, put it in backwards, or connect the coin-cell terminal as an ESP32 power supply.

A correctly configured RTC should keep counting on the backup cell, while the ESP32 itself shuts down when its supply is removed. Once power returns, the ESP32 reads the clock over I²C and obtains the elapsed time. The clock does not store time-zone rules or automatically synchronise itself over the internet.

Battery switchover setting and first-start behaviour

In Adafruit RTClib, adjust() not only sets time but also configures the PCF8523 battery switchover mode. Check initialized() and lostPower() when first bringing up a board. The oscillator-stop indicator can remain asserted briefly after initial power because the crystal requires time to stabilise; allow approximately two seconds on a fresh board before drawing conclusions from it.

Do not set the RTC on every boot. Doing so would overwrite its accurate battery-backed time with the sketch build time each time the ESP32 reboots. Use a conditional first-time adjustment or a deliberate manual/NTP synchronisation action.

Bare PCF8523 SOIC-8 chip pinout and functional reference

NXP’s datasheet specifies the following SO8 top view. The pin-1 indicator appears at the upper left: pins 1–4 descend along the left edge; pins 8–5 descend along the right. This is not the same as looking at the solder side of a breakout PCB.

Chip pinSignalPurpose
1OSCI32.768 kHz crystal input; high-impedance oscillator net
2OSCO32.768 kHz crystal output; keep layout very short
3VBATSeparate battery backup input
4VSSGround reference
5SDAI²C data input/output
6SCLI²C clock input
7INT1/CLKOUTOpen-drain interrupt or configurable clock output
8VDDMain power supply
PCF8523 SOIC 8 chip top view pins 1 OSCI 2 OSCO 3 VBAT 4 VSS 5 SDA 6 SCL 7 INT1 CLKOUT 8 VDD plus functional net table
Verified NXP SOIC-8 chip orientation; no invented tracks, PCB schematics or misleading drawn wires.

For a custom board, the quartz oscillator pins require a carefully designed, low-noise layout with the crystal and its specified load configuration; the supply requires adequate decoupling and the I²C lines require pull-ups chosen for bus capacitance and operating speed. An Adafruit breakout already provides those elements. The chip-level reference is not a full manufacturing schematic.

ESP32-to-PCF8523 connections: wire-free lookup table

Classic ESP32-WROOM DevKitAdafruit PCF8523Function
3V3VCC / VIN, follow PCB marking3.3 V main logic supply
GNDGNDShared ground
GPIO21SDAI²C data
GPIO22SCLI²C clock
Optional GPIO25 inputSQWOptional status/clock interrupt with verified pull-up to 3.3 V
No ESP32 connectionCoin-cell holderBackup supply to PCF8523
No additional connection neededSecond STEMMA QT socketOptional chaining connector, not necessary
ESP32 PCF8523 pin to pin connection tables 3v3 ground GPIO21 SDA GPIO22 SCL and optional SQW no wires
The example uses a classic ESP32-WROOM development board. Other ESP32-C3, S3 and C6 models can use different GPIO pins.

Unlike a custom raw chip circuit, the breakout is designed for straightforward I²C use. A simple first test needs only four signal/power connections. Keep the I²C clock at 100 kHz until the bus is working; higher speeds require short wiring and compatible pull-ups. If an ESP32-C3, C6, S3 or another board is used, change the SDA and SCL GPIOs in the code to its actual safe pinout.

Arduino IDE: working Adafruit RTClib example

Install RTClib by Adafruit from the Arduino IDE Library Manager and any dependency suggested by the IDE (such as Adafruit BusIO). Select the correct ESP32 development board and open Serial Monitor at 115200 baud. This example initialises the I²C interface, checks the clock, sets compile time only when it appears uninitialised or to have stopped, then reads current time once a second.

#include <Arduino.h>
#include <Wire.h>
#include <RTClib.h>

constexpr int I2C_SDA = 21;  // Classic ESP32-WROOM DevKit
constexpr int I2C_SCL = 22;
RTC_PCF8523 rtc;

void setup() {
  Serial.begin(115200);
  delay(400);
  Wire.begin(I2C_SDA, I2C_SCL);
  Wire.setClock(100000);

  if (!rtc.begin(&Wire)) {
    Serial.println("PCF8523 not detected at I2C 0x68");
    Serial.println("Check VCC=3.3V, GND, SDA and SCL.");
    while (true) delay(1000);
  }

  // Crystal start-up may require ~2 s on a new board.
  delay(2000);

  if (!rtc.initialized() || rtc.lostPower()) {
    Serial.println("Clock needs time setting.");
    // Uses build computer's time, NOT actual live UTC.
    rtc.adjust(DateTime(F(__DATE__), F(__TIME__)));
  }

  rtc.start();
  Serial.println("PCF8523 ready.");
}

void loop() {
  DateTime t = rtc.now();

  Serial.printf("%04u-%02u-%02u %02u:%02u:%02u\n",
                (unsigned)t.year(), (unsigned)t.month(),
                (unsigned)t.day(), (unsigned)t.hour(),
                (unsigned)t.minute(), (unsigned)t.second());

  delay(1000);
}

This sketch uses RTClib methods begin(&Wire), initialized(), lostPower(), adjust(), start() and now(), as defined in the official library API. It has not been physically bench-tested here. The initial compile-time setting is only a convenience for a first test, and could be minutes or hours behind real time after a delayed upload. For an internet-connected product, use ESP32 NTP to set an explicit UTC time instead.

Example Serial Monitor output

PCF8523 ready.
2026-11-04 12:00:01
2026-11-04 12:00:02
2026-11-04 12:00:03

The output above is illustrative and not a live measurement. The PCF8523 holds calendar fields but not a time-zone or daylight-saving definition. UTC timestamps are usually easier for sensor data logging; convert for display rather than silently changing the RTC itself twice per year.

Square-wave output, alarms and countdown timers

The PCF8523 supports a programmable clock output (SQW) and interrupt-related functions. The Adafruit breakout brings out a single SQW pin rather than every possible package output. On the SO8 version, its shared signal is INT1/CLKOUT; some other chip packages expose additional functions, which must not be mistaken for extra header pins on the breakout.

The square-wave frequencies supported by Adafruit’s current RTClib enum include 1 Hz, 32 Hz, and approximately 1, 4, 8, 16 and 32 kHz. The manufacturer also provides a calendar alarm and programmable timers. Keep the output open-drain nature in mind: if you read SQW with an ESP32 input, it needs an appropriate pull-up to the ESP32’s 3.3 V logic level.

// Optional, after rtc.begin() and time initialisation:
// rtc.writeSqwPinMode(PCF8523_SquareWave1HZ);
// Use a 3.3V-pulled-up input to read the SQW output.
// rtc.writeSqwPinMode(PCF8523_OFF); // disable

PCF8523 drift calibration: when and how to use it

The PCF8523 is not temperature compensated like the DS3231, but it does have a signed correction register that can be used to reduce measured frequency error. The available range is -64 to +63 calibration steps. Adafruit’s RTClib offers calibrate(PCF8523_TwoHours, offset) and calibrate(PCF8523_OneMinute, offset). The first mode changes the rate by approximately 4.340 ppm per step; the second uses about 4.069 ppm per step.

A +1 offset makes the clock slower; -1 makes it faster. Do not tune it at random. First compare the module against a trustworthy time source over several days, calculate its observed rate error, and then apply a small correction, testing again. Crystal drift from changing ambient temperature cannot be perfectly eliminated by a single fixed offset.

PCF8523 RTC drift offset ppm two hours one minute RTClib calibration SQW alarm countdown timer modes table
Correction is based on measured clock error, not a factory-guaranteed accuracy claim. Timer and CLKOUT settings share the available chip output functions.
Error / taskRecommended action
Clock gains 1–2 seconds each dayMeasure the error rate over several days; consider an appropriate small positive calibration offset
Clock loses 1–2 seconds each dayMeasure first, then consider an appropriate small negative offset
Square-wave output seems stuckCheck RTClib SQW mode, relevant output-enable settings, and the required 3.3 V pull-up
Need a wake-up eventUse the PCF8523 alarm/timer and an ESP32 wake-capable GPIO appropriate to your model
Need high clock accuracy without calibrationConsider DS3231, which has an integrated temperature-compensated oscillator

PCF8523 versus DS3231: which RTC should you choose?

CharacteristicPCF8523DS3231
Clock architectureExternal 32.768 kHz crystal, no active temperature compensationIntegrated temperature-compensated oscillator
Typical practical accuracyCan drift about 1–2 seconds/day; calibratableTypically far better: specified ±2 ppm over 0–40 °C for common version
I²C addressFixed 0x68Fixed 0x68
Battery backupBuilt-in switchover, very low backup powerBuilt-in backup, accurate power-off clock
Special featuresAlarms, timers, square-wave, drift offsetTwo alarms, square-wave, temperature reading, aging offset
Good fitSimple low-power clocks, educational hardware, calibration experimentsOffline timestamps when higher accuracy matters

Your site already covers ESP32 I²C troubleshooting in the I²C scanner guide. Once the DS3231 breakout-reference draft is published, it can also be internally linked here to form a tight two-article RTC cluster.

PCF8523 common problems

SymptomCheck
No device at 0x68VCC 3.3 V, GND, SDA/SCL labels, ESP32 pin mapping, power wiring, and the installed I²C pull-ups
Scanner finds 0x68 but time looks wrongClock may never have been set or has stopped; check initialized() and lostPower()
Time resets when power removedCR1220 missing, exhausted, reversed or poor contact; battery switchover not configured
Time differs after a sketch uploadCompile timestamp was not live time; set RTC by NTP/UTC or manual trustworthy time
Clock loses time regularlyQuartz tolerance and temperature drift; check RTC offset calibration and crystal integrity
Cannot communicate with DS3231 as wellBoth devices have 0x68; put them on separate I²C buses or multiplexer channels
SQW not changing stateConfirm chosen SQW mode and open-drain pull-up to 3.3 V
Board gets hot / ESP32 misbehavesWrong supply, shorts, or 5 V I²C pull-ups applied to ESP32 GPIO. Disconnect and inspect before reuse

Frequently asked questions

Is the PCF8523 I²C address 0x68 or 0xD0?

Both represent the same slave in different conventions: 0x68 is the seven-bit address used by Arduino; 0xD0 is an eight-bit write address. Use 0x68 in code.

Does PCF8523 have an address jumper?

No. The normal PCF8523 address is fixed at 0x68. A solder pad on an unfamiliar generic module should not be assumed to be an address selector.

Does it charge its CR1220 battery?

No. The Adafruit PCF8523 backup holder is intended for a non-rechargeable CR1220, and the breakout is not a battery charger. Follow Adafruit’s product instructions and do not confuse it with charging circuits found on some unrelated DS3231 modules.

Can the PCF8523 and DS3231 share SDA and SCL?

Not directly on the same bus segment if independent access is needed, because both answer at 0x68. Separate buses or a multiplexer can isolate them.

Is the PCF8523 still being manufactured?

NXP’s current product page marks the PCF8523 as no longer manufactured. Finished Adafruit breakouts may remain in stock, but check availability before selecting the chip for a new long-life design.

Technical references

Editorial verification: All electrical connections are provided as checked pinout tables with no drawn wires; do not substitute the generic module’s physical pad order for Adafruit’s. The example uses an ordinary ESP32-WROOM DevKit and the published RTClib API, but has not been physically bench-tested.

CONTINUE EXPLORING / ARDUINO

Read next

Practical guides related to this article.

Explore the topic →
HARDWARE DECISION GUIDEArduino or ESP32 for your next build?

Compare practical options before you choose hardware.

Compare options →