ESP32 w/SD Card as USB Memory Stick

Ideally, plugging in the ESP Dev board with an SD Card module would look and function just like a USB Memory Stick.

Then every XX minutes, the ESP would read that same SD and preform functions if there have been any changes to the directory.

Many other closed threads here say this is not possible.
But it appears to be done here for a 3D Printer application using the ESP8266.

FYSETEC WiFi-SD
https://github.com/ardyesp/ESPWebDAV

(note: the card in this case is being read by a 3d printer. but this would not appear to be any different than being written or read by a PC) The ESP would not be writing to the SD. Just reading on a timed basis.
In a perfect world with code to detect whether the CD was being accessed by the PC.

Is this physically impossible, or just difficult due to the danger (that code might solve) of simultaneous access?

The project you link to needs a client on the PC to interface with the WebDAV server to access files and it is not something the operating system can do natively.
Ideally you need an MCU with native USB support as you cannot do this through a USB/UART interface chip as used on most ESP development boards.
I think there is now a variant of the ESP that does have built in USB but I know nothing of what it is capable of on USB.
The Teensy used to have a storage endpoint on it's native USB but I have never used it or know if it works/worked.

I'm tempted to accept defeat. There are no less than a dozen other posts over the last two years asking some variation of this same question. All answered by people far more knowledgeable with an "it's not possible" reply.

But... I know that i can wire the SD card to a USB connector without the ESP32 and create a memory stick.
And I know I can attach the ESP to the SD card and read it and transmit files to and from it over WiFi. That's pretty much what every SD project here is doing in some form.
And it seems to make sense that if I had a switch, I could switch connections between the two so that each could access the SD card at different times. That's the fundamental equivalent of physically pulling it out of one device by hand and putting it into another.
So in my imagination, it seems reasonable to suspect that I could either add some kind of switch chip that the ESP could control to achieve that so both machines aren't trying to access the disk at the same time. Or perhaps not even have to worry about that because it's something the SD card circuitry already deals with on any multi-core computer.
Am I totally off base here? Give me some of that hacker ingenuity and can-do spirit! This seems like a fun puzzle that needs solving. So many projects here would benefit from the ability to load and retrieve files from an SD thru that USB port. :slight_smile:

That sounds unlikely, USB and SPI are totally different. Do you have any references to that?

1 Like

I clearly do not. Pardon my ignorance and thanks.
I now understand that a chip and resistors sit in the middle of that connection as seen here:

https://www.fasttech.com/product/9680694-sanwu-hf201-microsd-card-mobile-phone-memory-card

Complexity has certainly increased. But I think the basic premise still stands. Both the PC and the ESP32 can read the MicroSD in their own way separately (right?). And switching between them would (again, I assume) be the equivalent of pulling the card out manually and swapping it between machines.
So I'm still searching for a way to enable the ESP to periodically read from the MicroSD while it remains connected to the PC.

Does the new ESP32 S3 change the answer to this question?

https://docs.espressif.com/projects/esp-idf/en/latest/esp32s3/hw-reference/esp32s3/user-guide-devkitc-1.html

As far as I can tell the ESP32-S3 is not currently supported by arduino-esp32. But the ESP32-S2 is supported and it has USB hardware. A USB Mass Storage example is included. I have very little experience with ESP32 S2 so I will not be trying this any time soon. But it would be interesting to hear about some hand-on experience.

Note CircuitPython and (I think MicroPython) use this feature on ESP32 S2 boards so these boards appear as USB hard drives.

Same with RP2040 Pico board, it presents a virtual drive for drag 'n drop python operations.
One can even build a UART-USB bridge
https://forums.raspberrypi.com/viewtopic.php?t=302684

Pico’s BOOTSEL mode lives in read-only memory inside the RP2040 chip, and can’t be overwritten accidentally. No matter what, if you hold down the BOOTSEL button when you plug in your Pico, it will appear as a drive onto which you can drag a new UF2 file.

Seems this has been hashed over previously:
https://forum.arduino.cc/t/sd-card-to-usb/414380/3

Yes, RP2040 (Pi Pico) and ESP32 S2 both depend on tinyUSB for MSC so in theory both should work. The OP is looking for network access as well so the ESP32 S2 is better.

This topic was automatically closed 120 days after the last reply. New replies are no longer allowed.