Skip to content

DS1307 Module

This module implements the Zerynth driver for the Maxim DS1307 RTC (datasheet).

Using the module is simple:

from maxim.ds1307 import ds1307
import streams

ds = ds1307.DS1307(I2C0)

while True:
    print("%02d:%02d:%02d - %02d/%02d/%d - %d"%ds.get_time())

DS1307 class

class DS1307

class DS1307(drvname)

Creates a DS1307 instance using the MCU I2C circuitry drvname (one of I2C0, I2C1, … check pinmap for details). The created instance is configured and ready to communicate.

DS1307 inherits from i2c.I2C, therefore the method start() must be called to setup the I2C channel before the RTC can be used.



Returns a tuple (hours,minutes,seconds,day,month,year,day_of_week) with the current time and date readings.

Current time is always expressed in the 24 hours format.

The time and date readings conversion algorithm assumes that the DS1307 has been previously configured with a call to set_time().



Configures the DS1307 with time hours:minutes:seconds expressed in 24 hours format. The value of year must be greater or equal than 2000 and day_of_week must be in range 1 to 7 included.