-
Notifications
You must be signed in to change notification settings - Fork 42
MicroPython: SDCard
Leo Vidarte edited this page Mar 7, 2017
·
3 revisions
Ref: Adafruit - MicroPython Hardware: SD Cards
Download the sdcard.py module. Next use a tool like ampy to copy the sdcard.py
file to the root of the board's filesystem:
$ ampy --port /dev/ttyUSB0 put sdcard.py
Mount SD Card:
>>> import machine, sdcard, os
>>> sd = sdcard.SDCard(machine.SPI(1), machine.Pin(15))
>>> os.umount()
>>> os.VfsFat(sd, "")
>>> os.listdir()
['somefile']
Then write a file
>>> f = open('test', 'w')
>>> f.write('hello world')
11
>>> f.close()
>>> os.listdir()
['somefile', 'test']
Then read a file
>>> f = open('test', 'r')
>>> f.read()
'hello world'
>>> f.close()
ESP8266 NodeMCU Workshop - 2017