Lolin D32 PRO and SD Card Errors

All ESP32 boards running MicroPython.
Target audience: MicroPython users with an ESP32 board.
Post Reply
jamonda
Posts: 36
Joined: Thu May 21, 2020 3:48 pm

Lolin D32 PRO and SD Card Errors

Post by jamonda » Thu Aug 26, 2021 7:21 pm

Hi, friends.
A long time ago I used to mount SD Cards with my Lolin D32 PRO using this code and the sdcard.py driver:

Code: Select all

import machine, sdcard, os
sd = sdcard.SDCard(machine.SoftSPI(baudrate=100000, polarity=1, phase=0, sck=machine.Pin(18), mosi=machine.Pin(23), miso=machine.Pin(19)), machine.Pin(4))
os.mount(sd, '/sd')
Now with Micropython v1.16, when I try this code I get this error message:

Traceback (most recent call last):
File "<stdin>", line 1, in <module>
OSError: [Errno 19] ENODEV

After reading the v.1.16 docs, I tryed machine.SDCard() with this code:

Code: Select all

import machine
sd=machine.SDCard(sck=18, cs=4, miso=19, mosi=23)
import os
os.mount(sd, '/sd')
It didn't work either, giving me this error message:

Traceback (most recent call last):
File "<stdin>", line 1, in <module>
OSError: 16

The SD Card is good, as I can mount, read and write with my Pyboards.

What am I doing wrong?

Thanks in advance!

User avatar
Mike Teachman
Posts: 155
Joined: Mon Jun 13, 2016 3:19 pm
Location: Victoria, BC, Canada

Re: Lolin D32 PRO and SD Card Errors

Post by Mike Teachman » Fri Aug 27, 2021 1:40 pm

I use the same dev board. Here is what works for me in the v1.16 release:

Code: Select all

    
import os
from machine import Pin    
from machine import SDCard
sd = SDCard(slot=3, sck=Pin(18), mosi=Pin(23), miso=Pin(19), cs=Pin(4))
os.mount(sd, "/sd")

jamonda
Posts: 36
Joined: Thu May 21, 2020 3:48 pm

Re: Lolin D32 PRO and SD Card Errors

Post by jamonda » Fri Aug 27, 2021 2:57 pm

It worked here, Mike.
Thank you so much!

Post Reply