Skip to content

SDcard save year #626

@Gianfilippo980

Description

@Gianfilippo980

Whenever I write a fie to a MicroSD card from my Raspberry Pi Pico, if I open the card in a computer the date in something like 05/03/2103 (current date +80 years).
I am sure that the RTC on the Pico is set correctly (i do write a timestamp in the file, and I tested with it connected to a PC with Thonny which syncs it up). This is not a deal breaker, as I said, I do write a timestamp in the file, but it looks strange.

I downloaded the sdcard.py file a couple of days ago from this repository and my Pico is running MicroPython 1.19.
The simplest code that I tried is:

import sdcard
import uos

# Assign chip select (CS) pin (and start it high)
cs = machine.Pin(17, machine.Pin.OUT)

# Intialize SPI peripheral (start with 1 MHz)
spi = machine.SPI(0,
                  baudrate=1000000,
                  polarity=0,
                  phase=0,
                  bits=8,
                  firstbit=machine.SPI.MSB,
                  sck=machine.Pin(18),
                  mosi=machine.Pin(19),
                  miso=machine.Pin(16))

# Initialize SD card
sd = sdcard.SDCard(spi, cs)

# Mount filesystem
vfs = uos.VfsFat(sd)
uos.mount(vfs, "/sd")

try:
    open("/sd/non.txt", "r")
except:
    print ("Non c'è")
else:
    print ("C'è")

# Create a file and write something to it
with open("/sd/test01.txt", "w") as file:
    file.write("Hello, SD World!\r\n")
    file.write("This is a test\r\n")

# Open the file we just created and read from it
with open("/sd/test01.txt", "r") as file:
    data = file.read()
    print(data)```

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions