from machine import I2C, Pin
import oled
import time
import utime
from rtc import RTC # Ensure you have the correct library for your RTC
# I2C setup
i2c = I2C(0, scl=Pin(22), sda=Pin(21), freq=400000)
# OLED setup
oled_width = 128
oled_height = 64
oled = oled.SSD1306_I2C(128, 64, i2c)
# RTC setup
rtc = RTC(i2c)
while True:
# Read date and time from RTC
date = rtc.get_date_string()
time = rtc.get_time_string()
# Show date/time in screen
oled.fill(0)
oled.text(date, 22, 20)
oled.text(time, 30, 40)
oled.show()
utime.sleep(0.1)