SPI interface error when OV2640 and SD adaptor both connected to Arduino Nano

Hi all, hoping someone can help with a SPI conflict problem. I’m using an Arduino Nano with an OV2640 (Arducam Mini 2MP Plus) and a microSD card adapter. Individually everything works — I tested nano+OV2640 and nano+microSD adapter separately and both are fine. But when I connect both at the same time, the serial monitor just keeps printing “SPI interface error”.

Stuff I tried:

  • Without changing the camera wiring, I connected the SD adapter’s wires to the same pins as the camera.
  • I also followed the wiring from lab.dejaworks.com Arduino Nano SD card connection (http://lab.dejaworks.com/arduino-nano-sd-card-connection/).
  • If I disconnect power to the adapter, the camera works fine. If I disconnect camera power, the adapter works fine. So it only breaks when both are powered/connected together.

My guess is the ArduCAM bus goes wrong when both share the bus. Has anyone hit this?

Second question: how do I actually modify OV2640 exposure settings/registers? For example switching register 40’s bit[5] from 0 to 1, or modifying Saturation2. I tried putting read_reg/write_reg in the code but never got it to work. Would love a small code example showing how to flip a specific register bit.

Setup: macOS Big Sur, Arduino 1.8.19, microSD card adapter, Samsung/gigastone 32GB SD card, OV2640 (Arducam mini 2mp plus), Arduino Nano.

Attached a couple of photos of my setup:
WechatIMG49.jpeg
WechatIMG1.jpeg

For the register-modification part of your question, the best reference is the OV2640 register/datasheet. That lists which registers and bits control the things you’re after (exposure, register 0x40 bit[5], Saturation2, etc.), and you can cross-check the read_reg/write_reg calls in the ArduCam 2MP Plus functions against it.

You can reference this: https://datasheetspdf.com/datasheet/OV2640.html

Once you know the exact register/bit you want, use the library’s write_reg()/read_reg() on that register address and mask just the bit you want to change, instead of overwriting the whole byte. Let me know the specific register values you’re trying to set and I can point you at the right bit.

Adding to my previous inquiry — I’ve now tested this Nano, microSD adapter and OV2640 many times. I made sure that either the adapter OR the camera works on its own, but together I still always get the SPI interface error.

My conclusion is that this microSD card adapter just isn’t compatible with SPI when sharing the bus. Someone pointed me to this video and the same conclusion seems to come up (start around 6:15): Arduino ArduCam – Save Images to SD Card – Eli the Computer Guy

So my question: what microSD card adapter would you recommend I use instead? I want to buy the right one this time.

Thanks for the extra testing — that matches what we usually see with this combination.

The core problem is the circuit design of many SD card adapters: they don’t support tri-state (input/output and high-impedance state), so when they sit on the shared SPI bus they effectively hold/occupy the bus and conflict with the camera. That’s exactly why each device works alone but they fail together — the ArduCAM bus access gets blocked.

The fix is to use a standard SD card socket circuit — one that properly supports tri-state / high-impedance state — rather than the problematic microSD adapter. With a proper tri-state design, the bus goes idle after the SPI master finishes with one device, so the other device can be accessed without conflict.

Sorry if this is a dumb question — is a “standard sd card socket circuit” the same thing as the SD adapter? I’m searching on Amazon and there are so many kinds (the thin microSD-to-SD breakouts, the little adapters with level shifters, the bigger SD sockets, etc.). What keywords or other specifics should I look for so I buy the right one?

A good option is the Arducam Mini Multi-Camera Adapter Board. It’s designed for exactly this kind of multi-device setup and it can let you run up to four cameras together, plus there’s a working test demo you can use as a reference.

Adapter board: Arducam Mini Multi-Camera Adapter Board for Arduino
Example/demo code (ArduCAM_Mini_Capture2SD): Arduino/ArduCAM/examples/mini/ArduCAM_Mini_Capture2SD at master · ArduCAM/Arduino · GitHub

The Capture2SD demo shows camera + SD on the same SPI bus, which is basically what you’re trying to get working. Try that sketch as-is first before modifying anything.

OK, how do I wire this to an Arduino Nano though? The board page and the demo code don’t make the Nano pin mapping obvious to me — I’m not sure which pins go where.

Reference I’m looking at:

Here’s a picture of the board I’m looking at:
Catch.jpg

Quick correction — I re-checked the adapter board I linked earlier and I’m being told it’s currently out of stock, so you may need to pick an alternative adapter board instead.

Very important when you choose an alternative: ask the seller whether it supports three states (tri-state). If it doesn’t support high-impedance state, you’ll end up right back at the SPI bus conflict you already have. Don’t just go by size or price — confirm the tri-state behavior first.

What exactly do you mean by “the three states”? Not sure I follow.

Also, are there other smaller adapter modules on the market that work? I’d prefer something compact if possible.

Separate thing: I’d like to try Arducam Mega for this project, but I don’t think it’s macOS compatible yet. In Mr. Lee’s repositories I noticed there was a mac version of the HostV2 app — could a Mac version of the software for Arducam Mega be released? That would help a lot.

Catch(08-23-09-59-10).jpg

Good questions. Let me clear up the “three states” part first, because it’s the whole reason your two devices conflict.

The three states are the states the bus can be in depending on the circuit design: input (in), output, and high-impedance state.

  • Some defective SPI bus designs only support output mode. In that case you can’t put multiple SPI devices on the same bus, because the device will occupy/hold the bus and block everything else.
  • If the design supports high-impedance state, then after the SPI master finishes accessing one SPI device, the bus is made idle (high-Z) and that does not affect SPI bus access to other devices.

That’s why “does it support tri-state?” is the question to ask when picking an adapter — without high-Z, adding a second device on the bus is what causes the failure you’re seeing. So for smaller modules, you can look around, but the deciding factor is tri-state support, not the size.

On the Mac version: there is no released Mac version of the hostV2 app for Arducam Mega right now. To push for one, please pull a request to sales and describe your detailed requirement — email [email protected] with what you need.

Summary of where things stand: your SPI interface error is almost certainly the adapter’s lack of tri-state causing a bus conflict; use an adapter/SD socket circuit that supports high-impedance state (confirm with the seller). The Arducam Mini Multi-Camera Adapter Board I first linked is out of stock, so pick an alternative that explicitly supports tri-state and test with the ArduCAM_Mini_Capture2SD demo. For register tweaks (like reg 0x40 bit[5] or Saturation2), use the OV2640 datasheet to identify the register/bit and mask the single bit in write_reg(). And for a Mac hostV2 for Arducam Mega, request it through sales.