Hi everyone, I’m trying to get my Arducam OV2311 global shutter UVC camera to run in external trigger snapshot mode, but I’m stuck on the software side. I went through the docs here: Redirecting... and I honestly can’t find any indication of which program is actually being used in that demo. It just talks about accessing the camera but not what software is driving it.
What I actually want is to record videos with a different system while physically providing 5V TTL to control the frame rate. My recording workflow is Bonsai (the video/audio recording app referenced in the same thread), and I’d rather not switch away from it. Is that even possible, or does the camera require Arducam’s own software to do the external triggering? Any pointers would help, I feel like I’m missing something obvious.
Hey, no worries, this trips up a lot of people. The demo page you linked is really just about getting the camera to show up as a UVC device, it doesn’t cover the trigger part.
For external trigger, you want the snapshot-mode doc instead: Redirecting...
The camera doesn’t require Arducam software to be triggered. As long as it’s in external trigger mode, you can feed it a pulse on the trigger line and it will expose one frame per pulse, and any UVC recorder (Bonsai included) can capture the stream normally.
Before I go further, a couple of questions:
What exactly are you feeding it as the trigger signal right now?
Do you want each trigger pulse to produce one frame, or are you trying to gate a continuous frame rate?
Thanks, that doc clears up the software question, my recorder is fine then.
Here’s my real problem now. I don’t have an Arduino Due or an ESP8266, which is what the doc seems to assume you’ll use to generate the 3.3V external trigger signal. What I do have is a Raspberry Pi, but I’m not very familiar with it at all.
My setup: my program runs using an Arduino as an I/O, and the camera data interface is 5V while the external trigger level is 3.3V. What I want is a way to generate a 90 Hz 3.3V pulse that is gated by an incoming 5V pulse from the Arduino.
Okay, this is doable but there’s one hardware gotcha you need to respect first: the Raspberry Pi GPIO pins are 3.3V logic and they are NOT 5V tolerant. If you wire your Arduino’s 5V pulse straight into a Pi GPIO pin you can damage the pin (or worse). So the 5V input from the Arduino has to come down to 3.3V before it touches the Pi, either with a simple voltage divider (2 resistors) or a proper level shifter.
The output side is easy, the Pi outputs 3.3V natively, so that’s exactly what the camera’s trigger input wants.
For the 90 Hz generation, doing it in a plain Python loop won’t be stable, you’ll get jitter. Better to use the pigpio library, which can produce hardware-timed pulses on a GPIO pin. You’d trigger a 90 Hz waveform in a callback when your input pin goes high.
A couple of things:
Do you have the pigpio daemon available on your Pi? (usually just sudo apt install pigpio)
That trigger.py you found is written for Jetson, it won’t run as-is on a Pi. Can you paste what happens when you try it?
Okay good to know about the 5V thing, I had no idea the Pi pins weren’t 5V tolerant, I’ll use a divider before connecting.
On trigger.py, I copied it over and tried to run it on the Pi and it just blew up immediately. Here’s what I get:
$ python3 trigger.py
Traceback (most recent call last):
File "trigger.py", line 1, in <module>
import Jetson.GPIO as GPIO
ModuleNotFoundError: No module named 'Jetson'
So I guess it’s expecting the Jetson GPIO library which the Pi doesn’t have. I assume I need to rewrite the GPIO parts for the Pi. That’s kind of where I got lost, because the script does more than just blink a pin.
Also, just to be clear on what I need: it’s not one frame per pulse. I need the Pi to emit a continuous 90 Hz 3.3V pulse train on the trigger line, but only while/after it sees the 5V gate pulse from the Arduino. So the Arduino gates it on, and it should run at 90 Hz.
Right, that traceback confirms it. That script imports Jetson.GPIO and uses a few Jetson-specific things, so exporting it to the Pi means swapping the GPIO layer out. The overall structure is still useful though, it configures a trigger pin, sets up the camera trigger mode, and calls a waveform generator.
For the Pi the rough mapping is:
import Jetson.GPIO as GPIO becomes import RPi.GPIO as GPIO for basic setup, but for the actual 90 Hz train you really want pigpio instead of RPi.GPIO, since RPi.GPIO/Python timing will drift.
The continuous pulse train part maps to pi.hardware_PWM() or pi.wave_chain(), or you set the pin as a 50% duty 90 Hz using hardware_PWM(gpio, 90, 500000).
The gate: set up an edge callback on your input pin with pi.callback(gpio_in, pigpio.RISING_EDGE, cb), and in the callback start the 90 Hz output. Handle the falling edge to stop it if you want it strictly gated.
One question before you wire everything: how long is your 5V gate pulse from the Arduino, and how fast do you need the 90 Hz to start after the gate goes high? That affects whether a Python callback is fast enough or whether you need the Pi’s hardware PWM triggered directly.
Thanks, that’s a lot more concrete. Let me answer: the gate pulse from the Arduino is fairly short, maybe a few ms, and I need the 90 Hz to start basically right away, latency of a few hundred microseconds would be ideal but I could live with a bit more if it’s reliable.
I tried a quick test with pigpio to just see if I can get 90 Hz out of a pin at all, using hardware_PWM on GPIO 18. It runs but I noticed the waveform only comes out while the pigpio daemon is running, and if I stop the script the pin just stays at whatever state it was left in. Is there a clean way to have the output off by default and only enabled by the callback? I don’t want the camera getting a continuous trigger when the gate is low.
Yep, that’s expected, hardware_PWM keeps running in the background on the daemon, it doesn’t stop just because your script exits. Two things to make it safe:
Set the pin low on startup and register an atexit handler (or a try/finally) that calls pi.hardware_PWM(gpio, 0, 0) or pi.write(gpio, 0) before exit. Otherwise you leave the pin in an unknown state.
Don’t call hardware_PWM at startup at all. Only call it from inside the rising-edge callback, and stop it with duty 0 from the falling-edge callback. That gives you true gating: no gate pulse, no 90 Hz output.
Note the GATE pin still needs the 5V-to-3.3V divider in front of it. Give that a shot and tell me what you see on a scope, especially whether the start latency is acceptable.
Okay I wired it with a divider (1k/2k, so about 3.3V at the pin) and ran essentially your snippet. The gating works, when the gate goes high the 90 Hz appears and when it drops the output stops. So that part is good.
But I’m seeing something off: the first few pulses after the gate goes high look irregular compared to the rest, like the very first period is longer than the following ones. I don’t have a great scope, this is from a cheap logic analyzer. Is that just a limitation of starting hardware_PWM from a Python callback, or am I doing something wrong?
That’s a real limitation, not your wiring. hardware_PWM starts a fresh peripheral clock divider when you call it, so the first cycle after the call can be off by a chunk, and the Python callback itself adds a few tens to hundreds of microseconds of variable delay before the call even happens. On a proper scope you’d likely see the first period stretched, then it settles.
If the first-pulse irregularity matters for your capture (e.g. dropped or mistimed first frame), you have two realistic options:
Accept it and just discard the first frame after each gate, which is the pragmatic route for most recording setups.
Move the generation off the Pi entirely. A small dedicated generator (like the Arduino/ESP the docs assume, or a function generator with an external gate/trigger input) will give you a clean, deterministic pulse train that’s triggered by your 5V gate, with no software jitter. A function generator with a gate input does exactly what you’re describing hardware-wise.
Given you wanted the RPi route because you don’t have a Due/ESP8266, the question is whether the first-frame artifact is acceptable or not. What does the captured footage actually look like, are you seeing a bad first frame?
That makes sense, and yeah when I look at the captured stream the first frame after the gate tends to be the bad one, the rest of the burst is steady. So it sounds like the first-pulse jitter is exactly what I’m seeing.
My instinct is to just discard the first frame after each gate trigger, since the 90 Hz burst after that is clean on the logic analyzer. But before I commit to post-processing every capture, is there any config on the camera side (exposure/trigger delay settings) that could smooth out that first frame, or is this purely a signal-generation issue on my end? I’d rather fix it at the source if there’s a setting I’m missing.
Just to wrap up where this stands, since I don’t want to send you down a rabbit hole:
The docs you first linked don’t name the demo software because there isn’t a required Arducam recorder, external-trigger snapshot mode is driven purely by the signal on the trigger line, so Bonsai (or any UVC recorder) is fine.
To generate trigger pulses without a Due/ESP8266, the Pi works: GPIO is 3.3V output natively (matches the trigger input), and the 5V gate from your Arduino must go through a divider/level shifter before it reaches a Pi pin, since the pins aren’t 5V tolerant.
The provided trigger.py is Jetson-specific (that import Jetson.GPIO traceback), so it needs porting to RPi.GPIO/pigpio. Gating via rising/falling-edge callbacks plus hardware_PWM at 90 Hz, 50% duty, reproduces the behavior you wanted.
The remaining issue is the irregular first pulse/first frame after each gate. That’s coming from the Python-callback start of hardware_PWM, not from a camera exposure setting we’ve found, so there isn’t a camera-side fix I can point you to.
Current conclusion: the gating approach works, but the first-frame artifact is unresolved at the source. Practical workaround is the cleanest path for now: keep the Pi generating the gated 90 Hz and discard the first frame after each gate in your capture pipeline. If you need it clean at the source, a dedicated external generator with a gate input (or the Arduino/ESP approach from the docs) is the reliable route rather than tightening the Python timing.
If you do get a scope on it and the first period looks far more stretched than a couple hundred microseconds, post the trace here and we can look at whether it’s the callback latency or something in the divider wiring.