Hi everyone. I’m building a solar-powered trap/snapshot camera around a Raspberry Pi Pico, and I need some help getting two cameras running. Current setup uses a single Arducam Mega 3MP color rolling shutter module with an M12 lens over SPI, and the full_featured example from Arducam_Mega-2.0.9 works fine with that one camera. The end goal is that one external trigger captures one color photo and one IR photo in the shortest possible time, then the unit goes back to sleep since it’s battery/solar powered. We’re looking at around 1000 units, so I really need the software side solid.
Thanks for the background. A couple of quick questions to pin this down: which SPI bus is the current single camera on, and which chip-select pins are you planning for the two cameras? Also, just to confirm, you’re coding this in C/C++ on the Pico?
Sorry, yes — C/C++ on the Pico. SPI_1 is already taken by the SD card, so both cameras have to share SPI_0. My plan is to route the color camera’s CSn to GP17 (CS1) and the IR camera’s CSn to GP20 (CS2).
Got it, that matches what I’d expect. And for the baseline — with the stock full_featured example, the single color camera on SPI_0 produces valid images and no errors or logs show up, correct?
Correct. Single camera on SPI_0 works fine using the Pico full_featured example. I downloaded the library from the Arduino zip at https://downloads.arduino.cc/libraries/github.com/ArduCAM/Arducam_Mega-2.0.9.zip and ran Arducam_Mega-2.0.9\examples\Pico\full_featured. The problem is that the demo looks written for only one camera — I don’t see where to define a second chip select or a second camera instance.
That’s the root of it: the example as shipped only initializes one camera on SPI_0. It doesn’t cover two modules sharing the same SPI bus with separate chip selects. To make it work you’ll need to set up two camera objects on SPI_0 and manage the CS lines yourself — drive GP17 low before talking to camera 1, GP20 low before talking to camera 2 — so only the selected camera is active on the bus at a time. The SPI clock/data lines stay shared, but the CS handling has to be explicit.
That’s what I was afraid of. How do I actually modify the code? The example seems to handle SPI init and CS inside the library, so do I need to edit the library itself or just my sketch? Also, is there a reference example for two Arducam Mega modules on one SPI bus?
The 2.0.9 example set doesn’t have a two-camera-on-one-SPI reference, which is why this needs customization. In most cases you can leave the library alone and do the wiring/selection in your application: initialize SPI_0 once, create two camera instances, then set/clear GP17 or GP20 around each read/write. But keep your timing requirement in mind — you want the color and IR captures as close together as possible after the trigger. Since it’s solar powered, you’ll also want the cameras in standby or powered down until the trigger, then wake fast, capture both, and return to sleep. The motorized focus per install distance is separate, but the same init/CS flow applies.
Understood on the timing and power side — fast wakeup and shortest trigger-to-capture time is the whole point for this trap camera. But I’m still stuck on the code. If I create two camera objects, how do I make sure the library doesn’t fight over SPI init, and where exactly do I inject the CS toggling in the capture sequence? I can share the init and capture section if that helps.
Yes, sharing your current init/capture section would let us point at the exact lines. To summarize where this stands: single camera on SPI_0 works with the stock full_featured demo, SPI_1 is reserved for the SD card, and running two cameras on SPI_0 using GP17 for CS1 and GP20 for CS2 requires customizing the initialization and CS handling — the shipped example simply doesn’t support that configuration. If you post the relevant code block, we can walk through the changes line by line.