Skip to content
php-baremetal REGISTRY
Publish a package

php-baremetal/rtc-pcf85063

bm-lib MIT

PCF85063 real-time clock driver for ext-i2c (Baremetal\I2c\Driver\Pcf85063).

bus: i2c

A driver for the PCF85063 real-time clock on I2C. It registers into ext-i2c's i2c_drivers registry, so a firmware built with it has the class Baremetal\I2c\Driver\Pcf85063: it extends Baremetal\I2c\Device, reads the date and time with now(), sets them with set(), and tells you whether the clock kept time.

The package requires ext-i2c, so requiring the driver alone is enough; conductor adds the I2C HAL for your SDK platform.

Install

In a project created with phpbm init:

bash
composer require php-baremetal/rtc-pcf85063

Example

php
<?php
use Baremetal\I2c\Bus;
use Baremetal\I2c\Driver\Pcf85063;

$rtc = new Pcf85063(new Bus(sda: 11, scl: 10)); // 0x51, 400 kHz

if (!$rtc->now()['valid']) {
    $rtc->set(2026, 10, 19, 9, 0, 0);           // only when the clock lost power
}

$t = $rtc->now();
printf("%04d-%02d-%02d %02d:%02d:%02d\n",
    $t['year'], $t['month'], $t['day'], $t['hour'], $t['minute'], $t['second']);

Documentation

License

MIT.

Read the full documentation