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¶
Hardware:
- Adafruit DS1307 RTC breakout (Product ID: 3296)
Software and Dependencies:
- Adafruit CircuitPython firmware for the supported boards: https://circuitpython.org/downloads
- Adafruit’s Register library: https://github.com/adafruit/Adafruit_CircuitPython_Register
- Adafruit’s Bus Device library: https://github.com/adafruit/Adafruit_CircuitPython_BusDevice
Notes:
- Milliseconds are not supported by this RTC.
- Alarms and timers are not supported by this RTC.
- Datasheet: https://datasheets.maximintegrated.com/en/ds/DS1307.pdf
-
class
adafruit_ds1307.
DS1307
(i2c_bus)[source]¶ Interface to the DS1307 RTC.
Parameters: 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 sensorimport time import board import adafruit_ds1307
Once this is done you can define your
board.I2C
object and define your sensor objecti2c = 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
-
datetime
¶ Gets the current date and time or sets the current date and time then starts the clock.
-
datetime_register
¶ Current date and time.
-
disable_oscillator
¶ True if the oscillator is disabled.
-