from machine import Pin, I2C
from ds1307 import DS1307
from time import sleep
from ssd1306 import SSD1306_I2C
i2c = I2C(0,scl=Pin(1),sda=Pin(0))
rtc_time_module = DS1307(i2c)
oled = SSD1306_I2C(128,64,i2c)
while True:
current_time = rtc_time_module.datetime()
#2025-07-19
date_str = "Date: %04d-%02d-%02d"%(current_time[0],current_time[1],current_time[2])
#06:15:25
time_str = "Time: %02d:%02d:%02d"%(current_time[4],current_time[5],current_time[6])
oled.fill(0)
oled.text(date_str,0,10)
oled.text(time_str,0,30)
oled.show()
print("Date :",date_str,"Time :",time_str)
sleep(1)