Page 1 of 2

Is there anyone mount Sdcard successfully on ESP32 ??

Posted: Wed Feb 07, 2018 2:34 pm
by wasdwasd0105
I have tried few days on mounting the sdcard using the official driver https://github.com/micropython/micropyt ... /sdcard.py
(One this document,it does not show the information for ESP32) It keeps on failing showing message "OSError: no SD card". I have tried different spi order. So, is there anyone mount this sdcard successfully?

ALSO, on the ESP32 module, it contains the SDIO interface, however the official micropython doesn't provide a driver. So is it possible to add one?

Re: Is there anyone mount Sdcard successfully on ESP32 ??

Posted: Tue Mar 20, 2018 8:35 am
by symac
Just like you, I am quite new to micropython on esp32 and the first step for my project was/is to be able to read the content of a SD card and I am stucked there. I am still trying different pins configurations but for the time being, I always get the no sd card message.
Will update this thread if/when I am able to get something to work, but it would be great to have a precise howto regarding this point.

Re: Is there anyone mount Sdcard successfully on ESP32 ??

Posted: Tue Mar 20, 2018 9:53 am
by OutoftheBOTS_
There is a number of different ports for MicroPython on ESP32. I am using the unofficial one known as the the Laboris port. I have not had a problem with using the SD card with it in both 4 line mode and 1 line mode and do believe SPI mode has now been added to the port as well.
see laboris port wiki for info https://github.com/loboris/MicroPython_ ... ilesystems

Re: Is there anyone mount Sdcard successfully on ESP32 ??

Posted: Tue Mar 20, 2018 10:15 am
by symac
OutoftheBOTS_ wrote:
Tue Mar 20, 2018 9:53 am
There is a number of different ports for MicroPython on ESP32. I am using the unofficial one known as the the Laboris port. I have not had a problem with using the SD card with it in both 4 line mode and 1 line mode and do believe SPI mode has now been added to the port as well.
see laboris port wiki for info https://github.com/loboris/MicroPython_ ... ilesystems
Thanks for this lead. I will have a look at it tonight as "Loboris" seems to be something that is mentioned in other threads I have read regarding sdcards and micropython. Knowing it also works for you, confirms I need to have a look at it.

Re: Is there anyone mount Sdcard successfully on ESP32 ??

Posted: Tue Mar 20, 2018 12:56 pm
by LoRaTracker
Not directly related but I was just testing a micro SD card setup on a NodeMcu32s under Arduino.

The ESP32 hardware seems fussy about the type of SD card, the one I was intially testing with was not recognised at all, but it works fine on say a Arduino Pro Mini.

There have been quite a few comments on some SD cards not mounting with ESP32 Arduino port.

Re: Is there anyone mount Sdcard successfully on ESP32 ??

Posted: Wed Mar 21, 2018 5:27 am
by symac
Just tried to see if I got more luck using Loboris port and for the time being I am stucked. If someone reading this thread managed to use the SPI mode for a sdcard adapter, don't hesitate to commend on the edicated thread

Re: Is there anyone mount Sdcard successfully on ESP32 ??

Posted: Thu Apr 05, 2018 11:25 am
by rogierlodewijks
Don't know if this helps, but this code works for me, using the loboris uPy fork and using a FAT32 formatted SD card!

[code]
import uos
uos.sdconfig(uos.SDMODE_SPI, clk=14, mosi=15, miso=2, cs=13)
uos.mountsd(True)
uos.listdir()
[/code]

The pinning is for one of my ESP32 board (a TTGO with the 18650 battery on the back), so adjust pinout for your board.

Re: Is there anyone mount Sdcard successfully on ESP32 ??

Posted: Wed Apr 17, 2019 7:26 pm
by garlicbread
I've discovered that with the TTGO T8 boards (the ESP32 dev boards from aliexpress)
the sd card socket isn't wired to the hardware SPI pins
The pins in use for the TTGO T8 are
  • CLK / SCLK - IO14
  • DAT0 / DataOut / MISO - IO2
  • CMD / DataIn / MOSI - IO15
  • ChipSelect - IO13
So because of this we need to use software SPI to access the SD card

Place the sdcard module onto the device

Code: Select all

ampy -p COM7 put sdcard.py
Setup a software SPI port

Code: Select all

import machine, sdcard, os
from machine import Pin, SPI
spisd = SPI(-1, sck=Pin(14), mosi=Pin(15), miso=Pin(2))
Create an SD card class using pin 13 for the chipselect

Code: Select all

sd = sdcard.SDCard(spisd, machine.Pin(13))
mount the sd card under /sd

Code: Select all

os.mount(sd, '/sd')
to list the files

Code: Select all

os.listdir('/sd')
to unmount the card

Code: Select all

os.umount('/sd')

Re: Is there anyone mount Sdcard successfully on ESP32 ??

Posted: Thu Apr 18, 2019 10:25 pm
by garlicbread
Just to follow it looks as if the pinout is actually optimised for SDIO 4pin access I think instead of SPI access (which should be better)
But to use that you'll need SDIO support

The LoBo fork appears to have support for that (not tried it yet)

* https://github.com/loboris/MicroPython_ ... ilesystems

Re: Is there anyone mount Sdcard successfully on ESP32 ??

Posted: Mon Aug 10, 2020 1:28 am
by eighta
garlicbread wrote:
Wed Apr 17, 2019 7:26 pm
I've discovered that with the TTGO T8 boards (the ESP32 dev boards from aliexpress)
the sd card socket isn't wired to the hardware SPI pins
The pins in use for the TTGO T8 are
  • CLK / SCLK - IO14
  • DAT0 / DataOut / MISO - IO2
  • CMD / DataIn / MOSI - IO15
  • ChipSelect - IO13
So because of this we need to use software SPI to access the SD card

Place the sdcard module onto the device

Code: Select all

ampy -p COM7 put sdcard.py
Setup a software SPI port

Code: Select all

import machine, sdcard, os
from machine import Pin, SPI
spisd = SPI(-1, sck=Pin(14), mosi=Pin(15), miso=Pin(2))
Create an SD card class using pin 13 for the chipselect

Code: Select all

sd = sdcard.SDCard(spisd, machine.Pin(13))
mount the sd card under /sd

Code: Select all

os.mount(sd, '/sd')
to list the files

Code: Select all

os.listdir('/sd')
to unmount the card

Code: Select all

os.umount('/sd')
This solution works for me (very thanks), but before it worked, I was getting console errors.

After moving, removing and putting various things, the error I had was that my MicroSd Card Reader ONLY works with 5V :lol: