from machine import I2C, Pin
import utime
import ds3231_port
i2c = I2C(0, scl=Pin(9), sda=Pin(8))
rtc = ds3231_port.DS3231(i2c)
csv_filename = "data.csv"
with open(csv_filename, "w") as f:
    f.write("S.No,Time\n")
sno = 1
while True:
    year, month, day, hour, minute, second, weekday, _ = rtc.get_time()
    current_time = "{:02d}/{:02d}/{:04d} {:02d}:{:02d}:{:02d}".format(
        day, month, year, hour, minute, second)

    with open(csv_filename, "a") as f:
        line = "{},{}\n".format(sno, current_time)
        f.write(line)
        print(line.strip()) 

    sno += 1
    utime.sleep(1)

BOOTSELLED1239USBRaspberryPiPico©2020RP2-8020/21P64M15.00TTT
GND5VSDASCLSQWRTCDS1307+