lukasmaximus89
Published © CC BY

RTC Modules with M5Stack

Out of the M5Stack family only the M5StickC has an inbuilt RTC. Here's how to add one to your other M5Stack devices

IntermediateFull instructions provided5,509
RTC Modules with M5Stack

Things used in this project

Story

Read more

Code

RTC Basic program

MicroPython
A python script to display the date on the screen
from machine import I2C
import ds1307

i2c = I2C(1, I2C.MASTER, sda = 21, scl = 22)
ds = ds1307.DS1307(i2c)

#enable the osscilator
ds.halt(False)
ds.datetime()

#enter the current time (year, month, date, weekday, hour, minute, second, microsecond)
now = (2019, 11, 18, 1, 16, 20, 22, 0)
ds.datetime(now)

while(True):
    time = ds.datetime()
    lcd.text(0,0,str(time[0:8]),lcd.WHITE)
    

Credits

lukasmaximus89

lukasmaximus89

38 projects • 33 followers
I'm Luke from Manchester, UK. I've been living in shenzhen for 6 years. I do 3D design, Basic Electronics, Casting and other cool stuff.

Comments