Is there anyone mount Sdcard successfully on ESP32 ??

All ESP32 boards running MicroPython.
Target audience: MicroPython users with an ESP32 board.
Post Reply
wasdwasd0105
Posts: 3
Joined: Tue Feb 06, 2018 7:27 pm

Is there anyone mount Sdcard successfully on ESP32 ??

Post by wasdwasd0105 » Wed Feb 07, 2018 2:34 pm

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?

symac
Posts: 11
Joined: Thu Jan 04, 2018 2:01 pm

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

Post by symac » Tue Mar 20, 2018 8:35 am

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.

OutoftheBOTS_
Posts: 556
Joined: Mon Nov 20, 2017 10:18 am

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

Post by OutoftheBOTS_ » 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

symac
Posts: 11
Joined: Thu Jan 04, 2018 2:01 pm

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

Post by symac » Tue Mar 20, 2018 10:15 am

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.

LoRaTracker
Posts: 30
Joined: Sat Feb 25, 2017 8:24 am

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

Post by LoRaTracker » Tue Mar 20, 2018 12:56 pm

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.

symac
Posts: 11
Joined: Thu Jan 04, 2018 2:01 pm

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

Post by symac » Wed Mar 21, 2018 5:27 am

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

rogierlodewijks
Posts: 5
Joined: Sat Jul 15, 2017 7:13 pm

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

Post by rogierlodewijks » Thu Apr 05, 2018 11:25 am

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.

garlicbread
Posts: 4
Joined: Sat Aug 25, 2018 11:02 pm

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

Post by garlicbread » 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')

garlicbread
Posts: 4
Joined: Sat Aug 25, 2018 11:02 pm

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

Post by garlicbread » Thu Apr 18, 2019 10:25 pm

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

Post Reply