Kaluma library for DS1307 RTC module
npm install https://github.com/rossdoker/ds1307
Pi Pico | DS1307 |
---|---|
VBUS | VCC |
GND | GND |
SCL | SCL |
SDA | SDA |
const { I2C } = require('i2c');
const DS1307 = require('ds1307');
const i2c = new I2C(1, { mode: I2C.MASTER });
const ds1307 = new DS1307(i2c);
const date = new Date('2022-09-04T17:01:48.026Z');
ds1307.setDate(date);
setInterval(() => {
console.log(ds1307.getDate().toISOString());
}, 1000)
A class for DS1307 RTC module communicating with I2C interface.
Create an instance of bh1750 sensor.
bus
<I2C>
An instance ofI2C
to communicate.address
<number>
I2C slave address. (7bit). Default:0x23
.
Sets date to DS1307 module.
date
<Date>
JavaScript Date object to set.
Returns current date.
Returns
<Date>
JavaScript current date Date object.