Need manual exposure control code for Arducam Mega SPI 3MP-NoIR camera

I’m using the Arducam Mega SPI camera (3MP-NoIR, model 80435) in an application with fixed lighting and fixed distance, powered at 3.3V. Two big problems right now.

First, the current draw is way off from the published specs. The website says 56mA–136mA max, but I’m measuring 238mA continuously from power-on. I measured inline on the red wire across two different cameras — both read 238mA (±2mA). Voltage is steady at 3.3V with <50mV ripple, ambient temp around 74°F. This discrepancy already forced me to throw away a stencil and a set of production boards because my voltage regulator overheats and trips into circuit protection. That’s been costly.

Second — and more urgent — I need full manual control over this camera. My application has fixed lighting and fixed distance, so auto exposure is completely unacceptable. Everything needs to be locked down.

Right now my code is just:

cameraBegin(&Camera1);
cameraTakePicture(&Camera1, CAM_IMAGE_MODE_QVGA, CAM_IMAGE_PIX_FMT_RGB565);

I assume this defaults the camera to auto mode (auto exposure, etc.)? I haven’t implemented any manual control yet because I can’t find clear documentation on how to do it.

Specifically I need:

  • Example code to initialize the camera with complete manual control, all settings fixed
  • Code to change exposure manually
  • To know: are AutoExposure and WhiteBalance the only auto features? If I disable those, is everything else on the sensor under manual/fixed control?

I’ve been looking through the SDK docs here: MEGA SPI Camera - Arducam Wiki but haven’t found what I need.

Thanks for the detailed report. Let me address both issues.

Regarding the current draw: 238mA is definitely higher than the typical range in the published specs. The sensor can draw more current depending on operating mode — in auto exposure with certain scene conditions, the sensor may run at higher internal clock rates or gain levels that push current up. That said, 238mA is still notably high, and I’ll flag this for the team to review the published numbers. In the meantime, you’ll need to size your regulator for the measured draw, not the spec sheet.

Now, on manual control — this is absolutely doable with the library you’re using. You’re correct that calling cameraBegin() (or Camera1.begin() depending on the wrapper) starts the camera in auto exposure mode by default. The Arducam_Mega library has the functions you need — they’re just not obvious from the basic examples.

Here’s what you need:

#include “Arducam_Mega.h”

Arducam_Mega Camera1;

void setup() {
Camera1.begin();

// Disable auto features
Camera1.setAutoExposure(0);
Camera1.setAutoWhiteBalance(0);

// Set fixed manual values
Camera1.setAbsoluteExposure(10000);
Camera1.setISOSensitivity(256);

}

void loop() {
Camera1.takePicture(CAM_IMAGE_MODE_QVGA, CAM_IMAGE_PIX_FMT_RGB565);
}

The key functions are all declared in the library header: Arducam_Mega/src/Arducam_Mega.h at main · ArduCAM/Arducam_Mega · GitHub

  • setAutoExposure(0) — turns off auto exposure
  • setAutoWhiteBalance(0) — turns off auto white balance
  • setAbsoluteExposure(value) — sets a fixed exposure time
  • setISOSensitivity(value) — sets fixed sensor gain

You’ll need to experiment with the exposure and gain values. 10000 and 256 are just starting points — your fixed lighting setup will determine the right numbers. Take test shots, adjust, and repeat until the image looks correct. Call these after begin() and before you start capturing frames, and the camera should stay locked to your manual settings.

Thanks, that’s really helpful. I’ll start testing with those functions.

One follow-up before I dive in: are AutoExposure and AutoWhiteBalance the only two auto features on this camera? If I disable both and set manual exposure and gain, can I be confident that every other setting on the sensor is now under manual/fixed control? I want to make sure there isn’t some other auto feature I’m missing — like auto black level calibration or something else — that could still be adjusting things in the background frame-to-frame. My application absolutely cannot tolerate any parameter drifting between captures.

Good question. For the OV3640 sensor used on the Mega SPI, the two main automatic functions you need to worry about are auto exposure (which includes auto gain as part of its control loop) and auto white balance.

When you call setAutoExposure(0), the sensor stops automatically adjusting both exposure time and gain — that’s why you then set setAbsoluteExposure() and setISOSensitivity() manually. The AE algorithm normally controls both of those together, so disabling it and supplying fixed values locks them both down.

When you call setAutoWhiteBalance(0), the color gain channels are fixed rather than being continuously adjusted based on scene content.

There are other internal sensor functions like black level calibration, but those are handled at sensor initialization and don’t continuously adjust frame-to-frame in a way that would affect your application. With truly fixed lighting, you should get consistent frame-to-frame output once AE and AWB are disabled and your manual values are set.

One thing to watch: if your lighting source has any flicker (fluorescent tubes, some LED drivers), you may see variation even with fixed camera settings because the scene illumination itself is changing. But that’s a lighting issue, not a camera control issue.

Try the code above and see if the frame-to-frame consistency meets your needs. If you notice any drift or unexpected behavior, post back and we can dig deeper.