2 x esp32-s3 with 2 x sd-cards

I have a project that is gets data from BLE advertisements every few seconds and then periodically will upload this data to a mysql database with a POST request.

I have 2 x esp32s3-zeros and 2 sd card modules.

Here's a quick outline. The 2 esp32's (ESP A and ESP B) are both connected to the same SD cards (SD#1 and SD#2). ESP A saves data from non-connectable BLE advertisements to SD#1 and then every 10 minutes switches from saving data on SD#1 to SD#2, a signal is sent via GPIO to ESP B that this switch has happened - and ESP B then access SD#1 and uploads the saved data using POST request (I have a SIM7600 modem connected to ESP B for this).

The hope is for data from BLE advertisements to be continuously saved to one of the two SD cards by ESP A. The card that isn't being used for saving is then the source for the data to be uploaded by ESP B.

Is this possible - in theory I think it is but I am having issues with SD card initialization when there both ESP's are in the circuit - even if ESP B is not powered.

Here's how the SD cards are wired:

ESPA ESPB
GPIO 9 -> MISO SD1 and SD2 GPIO 9 -> MISO SD1 and SD2
GPIO 10 -> MOSI SD1 and SD2 GPIO 10 -> MOSI SD1 and SD2
GPIO 11 -> SCK SD1 and SD2 GPIO 11 -> SCL SD1 and SD2
GPIO 5 -> CS SD1 GPIO 5 -> CS SD2
GPIO 6 -> CS SD2 GPIO 6 -> CS SD1
3.3V Shared
GND Shared
GPIO 12 ESPA signal pin -> GPIO12 ESPB signal pin

I have 10k pull-up resistors on ESP B CS pins to keep HIGH by default.

Does anyone know if this can actually be done in practice or is there a better way to do this. I am not using FreeRTOS - I've no experience of this. I am trying to use one SPI Bus to save on GPIO pins.

Thanks for any help.

It can be done but it gets complicated. SPI is not designed for multiple masters.
However I2C can have multiple masters on the same bus. You might consider using I2C EEPROM instead of sd cards.

Thanks for the reply - I've re-thought how I'm going to do this now - I am going to use SPIFFS to log data to and then upload from there every hour. I should be able to do what I need to do with just one esp - the original project started to creep and I was over-complicating things.

Very much so.
Glad you figured out a simpler solution.

Your schematic would be much easier to follow if it weren’t presented as a "word salad." Have you considered using CAN (Controller Area Network)? It’s well-suited to this type of problem as it supports a multi-master bus architecture, making communication between devices more efficient and reliable.

Does SPIFFS access time increase as the file size increases?