MicroPython on ESP32-CAM using SD #15965
-
Using sdcard.py (via "import sdcard") is it possible to configure the SD card adapter to work as SPI? If so, could you help me? ESP32-CAM pin out it depicted below. No camera is connected to it. |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments 4 replies
-
Sorry... Should anyone get the same problem, here is the solution.
|
Beta Was this translation helpful? Give feedback.
-
You can use ESP-SDMMC instead of the SPI interface, here's how. Slot 1 At high speed frq = 40000000 you might (will) get A simple test script: import machine, os
from time import sleep
slt = 1 # slot 0 use by flash memory (1: default)
wid = 1 # sdmmc (sdio) - 1 bit at time (default). Either 1 or 4
# wid=1: Use GPIO: 15,14,2 (save 3 Pins)
# wid=4: Use GPIO: 15,14,2,4,12,13
# Data1@GPIO4, you will get flashing LED-flash
frq = 20000000 # defult:20000000 (or 10000000), high speed 40000000 (not stable)
sd=machine.SDCard(slot=slt, width=wid, freq=frq)
os.mount(sd, "/sd")
for i in range(100): # 100 frames video
print(gc.mem_free())
data = b'sfsdfsdfeqeqw12414asfasf33qrfsafq3r332rfsfsdff3r3232rgsdvdvwr3efes'*500
if len(data) > 0:
print('Frame:', i)
fn = '/sd/data-%03d.bin'%i
f = open(fn, 'wb')
w=f.write(data)
print(i,w,len(data))
f.close()
del f
sleep(0.5)
os.listdir("/sd")
os.umount("/sd") |
Beta Was this translation helpful? Give feedback.
-
My problem is actually solved. However, your solution may be very, very helpful if we need speed. This said, on a ESP32-CAM board I get:
|
Beta Was this translation helpful? Give feedback.
Try to unplug the board from the power source and plug it back in again. machine.reset() does not seem to work in this case.