npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@johntalton/pcf8523

v2.2.2

Published

Feature rich Real Time Clock including Alarm and Timers.

Downloads

13

Readme

pcf8523 (Real Time Clock)

Feature rich Real Time Clock including Alarm and Timers.

npm Version GitHub package.json version CI

Examples

Basic Time

Using the legacy Date object, the time can be set.

Note however, without enabling the proper Power Mode (aka, switch to battery when off line) this will only keep time while on main power.

It is also "recommended" to start/stop the oscillator when changing time (as well as most other time related parameters of the chip).

import { I2CAddressedBus, I2CBus } from '@johntalton/and-other-delights'
import {
  PCF8523,
  DEFAULT_PCF8523_ADDRESS,
  BASE_CENTURY_Y2K
} from '@johntalton/pcf8523'

const bus:I2CBus = /* ... */
const abus = new I2CAddressedBus(bus, DEFAULT_PCF8523_ADDRESS)
const device = new PCF8523(abus)

// should we store the clock using 24 hour or 12 hour
const ampm_mode = false // 24-hour

// the chip only stores last 2 digits, using this as the base
const century = BASE_CENTURY_Y2K

// get some time ...
const now = new Date(Date.now())

// the time can be manually constructed, here we use a helper
const time = encodeTimeFromDate(now)
await device.setTime(time, ampm_mode, century)

Update Control 1 Register (Stop Oscillator)

const device = new PCF8523(/* ... see basic example */)

// fetch current control and then set with override value
const current = await device.getControl1()
await device.setControl1({
  ...current,
  stop: true
})

Setting Power Mode

const device = new PCF8523(/* ... see basic example */)

await device.setControl3({
  // enable power switchover mode (this enable fallback to battery)
  // use standard mode
  pmSwitchoverEnabled: true,
  pmDirectSwitchingEnabled: false,

  // enable detection of low battery events (see interrupt enable bellow trigger)
  pmBatteryLowDetectionEnabled: true,

  clearBatterSwitchoverFlag: true, // clear any existing switchover events

  // enable both battery events to trigger an interrupt
  batterySwitchoverInterruptEnabled: true,
  batteryLowInterruptEnabled: true,
})

Interrupts

Support for multiple types of interrupts are supported. Note that this is independent of the Flags set (control 2 and 3). While multiple flags can be set, the chip has the ability to optionally expose those to the INT pin.

The Clock need to be disabled for interrupt pin to be valid.

The Second interrupt Flag will also only be enabled when the interrupt itself is enabled.

  • Timer A
  • Timer B
  • Alarm
  • Second timer
  • Battery switch-over
  • Battery low detection
  • Clock offset correction pulse