I’m working on 8.3 – Using a MicroSD Card for Datalogging in “Learn_Raspberry_Pi_Pico_W_with_MicroPython_V1”.
I had some difficulty, so I tried this tutorial:
“In-Depth Tutorial to Interface Micro SD Card Module with Arduino (lastminuteengineers.com)”
I was successful with it.
I’m enclosing a text file which explains the trouble I’m having with the 8.3 tutorial.
I’ve enclosed the link to front and back images of my MicroSD Card module. It doesn’t look exactly like the one in the tutorial!
https://imgur.com/a/T1FAsaO
OUTPUT of the prog.(On the Shell)
%Run -c $EDITOR_CONTENT
MPY: soft reboot
We’re going to INIT SPI
We’re going to Set CS pin
We’re going to setup SD obj
Note:
It appears to have not returned from the “sd = sdcard.SDCard(spi, cs)” statement!
AFTER a few minutes, it printed this on the Shell:
“An error occurred: timeout waiting for v2 card”
I’m wondering if I bought some older version 1 modules and this program requires version 2!!!
THE PROGRAM I RAN to GET THE PREVIOUS OUTPUT:
from machine import SPI, Pin
import sdcard, os
# Constants
SPI_BUS = 0
SCK_PIN = 2
MOSI_PIN = 3
MISO_PIN = 4
CS_PIN = 5
SD_MOUNT_PATH = ‘/sd’
try:
# Init SPI communication
print(“We’re going to INIT SPI”)
spi = SPI(SPI_BUS,sck=Pin(SCK_PIN), mosi=Pin(MOSI_PIN), miso=Pin(MISO_PIN))
print(“We’re going to Set CS pin”)
cs = Pin(CS_PIN)
print(“We’re going to setup SD obj”)
sd = sdcard.SDCard(spi, cs)
print(“We’re going to Mount SD card”)
# Mount microSD card
os.mount(sd, SD_MOUNT_PATH)
# List files on the microSD card
print(“We’re going to List files”)
print(os.listdir(SD_MOUNT_PATH))
except Exception as e:
print(‘An error occurred:’, e)
Hi.
How are you powering your microSD card?
I think those models require 5V to operate.
Connect the VCC pin to the Pin VBUS pin.
Let me know the results.
Regards,
Sara
Sara,
As usual, you provided the help I needed.
If only I would have thought of that!
Someday I’m gonna get smarter! (I really doubt it though, since I’ll be 80 in July)
It worked just as it is supposed to work.
Thanks again for your help.
Ray