crizeo wrote: ↑Tue Aug 08, 2017 10:44 am
For those still wondering
how to setup an SD card module on the ESP8266 using MicroPython 1.9.1 (as the process changed a bit, it is a lot easier now):
- Copy sdcard.py to the board (e.g. using ampy)
- Wiring SD card module <-> ESP8266 (GPIO):
- GND <-> GND
- DO/MISO <-> MISO (12)
- DI/MOSI <-> MOSI (13)
- CLK/SCK <-> SCK (14)
- CS <-> CS (15)
- VCC <-> VCC 3.3V/5V (Check your modules specification! If it has a voltage regulator on it (as mine), it probably requires 4.5~5.5V input, otherwise 3.3V. As the ESP8266 only supplies 3.3V output, you may need an external 5V power source. Some modules like the Feather HUZZAH are powered by USB and therefore have a 5V output (called USB / VBUS on the Feather). If not, connect the external power sources VCC to the SD modules VCC (and power sources GND to ESP8266 GND). If your module works with 3.3V you can simply connect VCC <-> VCC 3.3V of course)
- Hard reset the ESP8266 (this may be required or may not?)
- Run the following commands on your ESP:
Code: Select all
import os, machine, sdcard
sd = sdcard.SDCard(machine.SPI(1), machine.Pin(15)) # hard reset required after wiring
#os.umount('/') # only if you want to unmount flash (NOT REQUIRED!)
vfs = os.VfsFat(sd) # is this required?
os.mount(vfs, '/sd') # or '/' if you did the umount command before
#os.listdir() # you'll see a new '/sd' folder
#os.statvfs('/sd') # size of sd card = [0]*[2] bytes (free: [0]*[3])
os.chdir('sd') # to change directory (if you kept '/')
#os.listdir() # you'll see the sd card's contents (or listdir('/sd') from outside)
- copy sdcard.py to the board: check
- wiring sdcard-module: check
- hard reset: check
but:
Code: Select all
>>>import machine, os, sdcard
>>> sd = sdcard.SDCard(machine.SPI(1), machine.Pin(15))
>>> vfs = os.VfsFat(sd)
>>> os.mount(vfs, '/sd')
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
OSError: [Errno 19] ENODEV
Any idea about the problem and how to fix it?
I'm using a NodeMCU, a "CATALEX MicroSD Card Adapter", and a 8GB Micro-SDHC Class 10 Card.
The SD-Card is formatted to FAT32 (cluster sizes: 4.096)
I have found this one:
https://github.com/micropython/micropython/issues/3622
With "os.mount(sd, '/')" I was not able to fix it.
Unfortunately, there was no information about what the problem with the sd-card exactly was... :/ any idea?
thx
edit: there is no label with information about the manufacturer of the sd-card - but the sd-card was delivered with the MicroSD Card Adapter as a combo-package.