Comments on: Raspberry Pi Pico: MicroSD Card Guide with Datalogging Example (MicroPython) https://randomnerdtutorials.com/raspberry-pi-pico-microsd-card-micropython/ Learn ESP8266, ESP32, Arduino, and Raspberry Pi Mon, 21 Apr 2025 09:43:04 +0000 hourly 1 https://wordpress.org/?v=6.8.2 By: Sara Santos https://randomnerdtutorials.com/raspberry-pi-pico-microsd-card-micropython/#comment-1029367 Mon, 21 Apr 2025 09:43:04 +0000 https://randomnerdtutorials.com/?p=163477#comment-1029367 In reply to Kees.

Hi.
Did you specify the local time of the pico using the DS3231 module?
Can you show me the lines of code you used to do that?
Regards,
Sara

]]>
By: Kees https://randomnerdtutorials.com/raspberry-pi-pico-microsd-card-micropython/#comment-1029038 Sun, 20 Apr 2025 06:52:10 +0000 https://randomnerdtutorials.com/?p=163477#comment-1029038 Hi Sara,
Thank you for your reply.
Indeed what I have noticed of the time of creation of the file is beyond your example.
If I save your example as logdata.py and run it again with Thonny then, when I look in the Windows explorer, I see the actual time of the creation of the file temperature.txt
However when I upload logdata.py as main.py to the Pi Pico and I power-up the Pi Pico (as stand-alone module) then I see the time of the creation of the file as 2020-12-31 23:00:00, That’s right because the Pi Pico (as stand-alone module) has no idea what time it is. But as I wrote earlier I have combined this example with your other example about the use of the “on board” rtc module DS3231 and in that case I had expected that the time of the creation of the file should correspond with the actual time (with taking into account your comment of April 12, 2025 at 10:18 am of example https://randomnerdtutorials.com/raspberry-pi-pico-ds3231-rtc-micropython/). So I am referring to the time of the creation of the file that is produced by your both examples in one program. That file has still not the actual time of creation despite the presence of the DS3231 with the actual time.

]]>
By: Sara Santos https://randomnerdtutorials.com/raspberry-pi-pico-microsd-card-micropython/#comment-1028927 Sat, 19 Apr 2025 21:22:35 +0000 https://randomnerdtutorials.com/?p=163477#comment-1028927 In reply to Kees.

Hi.
I’m sorry, but I didn’t understand your question.
In this example we don’t log the time.
Are you referring to the time of the creation of the file? I haven’t noticed it.

What exception do you get?

Regards,
Sara

]]>
By: Kees https://randomnerdtutorials.com/raspberry-pi-pico-microsd-card-micropython/#comment-1028298 Thu, 17 Apr 2025 20:04:42 +0000 https://randomnerdtutorials.com/?p=163477#comment-1028298 Hi Sara,

I am still puzzling at which moment in the Pi Pico program main.py (your example with temperature.txt) is getting the system time, which, I guess, is responsible for the creation date of the file on the SD-card.
Is it right that I can check this time by utime.localtime() ?
And I have also inserted a line time.sleep(20) just before the line mount_sdcard(spi, cs) to insert the SD card as late as possible but just before the mount_sdcard function generates an Exeption.
Unfortunately this did not help to get the right file creation date.
Should this issue be solvable at all?

]]>
By: Kees https://randomnerdtutorials.com/raspberry-pi-pico-microsd-card-micropython/#comment-1027551 Tue, 15 Apr 2025 19:41:47 +0000 https://randomnerdtutorials.com/?p=163477#comment-1027551 Hi Sara,

I have used your tutorial and made a datalogging program (main.py) to log temperature, humidity and pressure (BME280) also as function of date and time to a file with an unique filename.
The unique filename has two parts, one is the word “log” and added with the formatted datetime which is coming available in your second tutorial Raspberry Pi Pico: DS3231 RTC (Real-Time Clock) – Get Time and Set Alarms (MicroPython). Your examples were a nice starting point to learn about the basic knowledge.
In that second tutorial (using the DS3231) I uploaded your program to the Pi Pico as main.py. Then a problem with logging the current date and time was created but meanwhile solved with your tips in the Comment below your tutorial Raspberry Pi Pico: DS3231 RTC (Real-Time Clock) – Get Time and Set Alarms (MicroPython).

After going on with my datalogging program I created, as said, a unique filename. This is done by getting the formatted_datetime for one time at the beginning of this datalogging program.
As an example “log2025-04-15-092345.txt” ( removed the colons in the time).
Then the datalogging program comes into in the While loop where the data is collected and written to the SD card etc.
After a certain time I open the Windows Explorer to see what is on the SD card.
I find the logfile “log2025-04-15-092345.txt” but the creation date (modified date) of the logfile is unfortunately 31-12-2020 time 23:00 (system time of Pi Pico?) and not the current time.
The column with timedata in the logfile which is generated by the datalogging program has the right current time.
Every time when I power up the Pi Pico the current time in the new logfile is logged ok, but the creation date/time (seen in the Windows Explorer) is not. It is always 31-12-2020 time 23:00.
I had hoped that the “system time” of the Pi Pico is updated first with the current time from the DS3231 as soon as the power of the Pi Pico is switched on.
I am describing here the results of the datalogging program as main.py

If I upload your example with temperature.txt as main.py to the Pi Pico and I check the file in Windows Explorer then I see also the creation date 31-12-2020 time 23:00

]]>