Page 1 of 1

very strange behavior with sd and nodemcu

Posted: Sat Apr 20, 2019 8:59 am
by nodepythoner
i connected sd module with nodemcu board(software spi) and wrote some code:

import machine, sdcard, os
Pin = machine.Pin
cs = Pin(0)
mosi = Pin(5)
miso = Pin(16)
sck = Pin(4)
spi = machine.SPI(-1,sck = sck, mosi = mosi, miso = miso)
sd = sdcard.SDCard(spi, cs)
vfs = os.VfsFat(sd) #eio
os.mount(vfs, '/sd')
os.chdir('sd')
f = open('test', 'w')
f.write('hello world')
f.close()

with 2gb sdcard i get
OSError: [Errno 5] EIO
in vfs = os.VfsFat(sd) line

with 4 gb card i get freeze of the board in
sd = sdcard.SDCard(spi, cs) line

micropython version: esp8266-20190125-v1.10.bin
sd library i downloaded here https://learn.adafruit.com/micropython- ... icropython (green button)

Re: very strange behavior with sd and nodemcu

Posted: Sat Apr 20, 2019 1:26 pm
by Roberthh
I'm using the same driver on a WEMOS D1 Mini with its SD card daughterboard. It works, but requires sometime a second reset or power cycle before the card is detected. Please take care that the cards only contain a single FAT or FAT32 partition. Upon delivery, Micro-SD cards ofter have another hidden partition, which does not interfere the regular operation systems, but confuses the simple SD card driver.

Re: very strange behavior with sd and nodemcu

Posted: Sat Apr 20, 2019 2:34 pm
by nodepythoner
with 4 gb card works well. i used 3.3v but this module working from 5 volts(it is module for arduino)
but with 2 gb card also EIO

Re: very strange behavior with sd and nodemcu

Posted: Sat Apr 20, 2019 4:03 pm
by Roberthh
I made the experience that not every card works. And a 5V module includes a regulator, which are not needed with the NodeMCU. Take care that the supply voltage of the SD card is sufficient. If the Module has a regulator, you may supply it with 5V. The output level of MISO should still be at 3.3 V.