adding an SDCard Example for the ESP-Wrover-kit
parent
ddfce83cb8
commit
8d7e83113b
@ -0,0 +1,13 @@
|
||||
# SD Card example
|
||||
|
||||
Here are the [docs for the SDCard pins](https://docs.espressif.com/projects/esp-idf/en/latest/esp32/hw-reference/esp32/get-started-wrover-kit.html#get-started-esp-wrover-kit-v4-1-microsd-card-slot).
|
||||
|
||||
| . | ESP32 Pin | MicroSD Signal |
|
||||
|---|---------------|----------------|
|
||||
| 1 | MTDI / GPIO12 | DATA2 |
|
||||
| 2 | MTCK / GPIO13 | CD / DATA |
|
||||
| 3 | MTDO / GPIO15 | CMD |
|
||||
| 4 | MTMS / GPIO14 | CLK |
|
||||
| 5 | GPIO2 | DATA0 |
|
||||
| 6 | GPIO4 | DATA1 |
|
||||
| 7 | GPIO21 | CD |
|
@ -0,0 +1,20 @@
|
||||
import machine, uos
|
||||
|
||||
# machine.SDCard(slot=1, width=1, cd=None, wp=None, sck=None, miso=None, mosi=None, cs=None)
|
||||
|
||||
sd = machine.SDCard()
|
||||
|
||||
uos.mount(sd, '/sd')
|
||||
|
||||
|
||||
def cat(file, encoding='utf8'):
|
||||
"""Prints the file."""
|
||||
with open(file, mode='r', encoding=encoding) as f:
|
||||
for line in f.readlines():
|
||||
print(line)
|
||||
|
||||
|
||||
def to_file(file, text='', encoding='utf8'):
|
||||
"""Simple function to write some text to a file."""
|
||||
with open(file, mode='r', encoding=encoding) as f:
|
||||
f.write(text)
|
Loading…
Reference in New Issue