Home

Awesome

Micorpython DS1302 RTC Clock driver

This is a pure Micropython DS1302 RTC Clock driver. This is based on microbit code of microbit-lib https://github.com/shaoziyang/microbit-lib

This has been tested and working on ESP32 but should work with any micropython supported device.

Dirver documentation

(Adapted from https://github.com/shaoziyang/microbit-lib/blob/master/misc/DS1302/README.md)

DS1302 is real-time clock (RTC) with serial interface, 31 * 8 data ram.

API

example

from machine import Pin
import ds1302

ds = ds1302.DS1302(Pin(5),Pin(18),Pin(19))

ds.date_time() # returns the current datetime.
ds.date_time([2018, 3, 9, 4, 23, 0, 1, 0]) # set datetime.

ds.hour() # returns hour.
ds.second(10) # set second to 10.