adafruit_ds1307 - DS1307 Real Time Clock module

CircuitPython library to support DS1307 Real Time Clock (RTC).

This library supports the use of the DS1307-based RTC in CircuitPython.

Beware that most CircuitPython compatible hardware are 3.3v logic level! Make sure that the input pin is 5v tolerant.

  • Author(s): Philip R. Moyer and Radomir Dopieralski for Adafruit Industries

Implementation Notes


Software and Dependencies:


  1. Milliseconds are not supported by this RTC.

  2. Alarms and timers are not supported by this RTC.

  3. Datasheet:

class adafruit_ds1307.DS1307(i2c_bus: I2C)[source]

Interface to the DS1307 RTC.


i2c_bus (I2C) – The I2C bus the device is connected to

Quickstart: Importing and using the device

Here is an example of using the DS1307 class. First you will need to import the libraries to use the sensor

import time
import board
import adafruit_ds1307

Once this is done you can define your board.I2C object and define your sensor object

i2c = board.I2C()  # uses board.SCL and board.SDA
rtc = adafruit_ds1307.DS1307(i2c)

Now you can give the current time to the device.

t = time.struct_time((2017, 10, 29, 15, 14, 15, 0, -1, -1))
rtc.datetime = t

You can access the current time accessing the datetime attribute.

current_time = rtc.datetime
property datetime: struct_time

Gets the current date and time or sets the current date and time then starts the clock.


Current date and time.


True if the oscillator is disabled.