Raspberry Pi Camera Shutter Speed control

Hi all,

I am using a Raspberry Pi Camera Module 3 to take an image of a chemical reaction inside a black box for a university project. I am attempting to keep the shutter open for a long period of time (60-100s) to capture as much light as possible. The documentation says that maximum exposure time is 112s for the camera module. When I read the metadata for how long the exposure time is, at values below 82992 microseconds, it runs correctly, however when I run the code for values above this time, it seems that 82992 is the maximum.

If anyone has any advice on how to achieve longer exposure, I would really appreciate it.

I am using the following code:

import time
import math
from picamera2 import Picamera2, Preview

picam = Picamera2()
file_name = "/home/xxx/Pictures/test_" + str(math.trunc(time.time())) + ".jpg"
print(file_name)
config = picam.create_preview_configuration()

picam.configure(config)
picam.start_preview(Preview.QTGL)

picam.start()
picam.set_controls({"ExposureTime": 1000000}) 
time.sleep(2)
metadata = picam.capture_file("file_name")
print(metadata)
picam.close()

Hi David,

I’m not sure why the maximum exposure time is limited to 112s, knowing where that limit has been inherited from might offer more ideas as to how to get around it, or may reveal why that limitation has been coded in.

This forum thread on the Raspberry Pi forums seems to indicate these maximum times have been inherited from the sensors themselves that are used in the camera module, but they also suggest there are workarounds with some versions of the HQ camera by manipulating the camera sync function.

https://forums.raspberrypi.com//viewtopic.php?t=290979

Hi Trent,

Thanks for taking the time to reply, 112s is more than sufficient for me at the moment so I dont need to work around it, however I cannot get the exposure past 828992 microseconds at the moment which seems bizarre.

If you know any different code to run that might allow for the exposure time to be extended beyond this, it would be a massive help.

Cheers,
Dave

Hi David,

I see what you mean, it appears the limitation you’ve hit for the exposure time is a result of the picamera2 library you are using.
I’ve had a look through the libraries documentation and it seems the minimum and maximum exposure time of the camera are set in that library. You can query the current minimum and maximum value of the mode your camera is operating in by checking the sensor_modes property of the picamera object.

Check out page 19 of this PDF under the heading Raw Streams, I think that might give us some more context on why it’s failing to expose for more than 82 milliseconds.

Hi All

Just a point. First post says 82mS the second says 828mS. It would probably be clearer if this was clarified. Wouldn’t be a timer running out of numbers by any chance, I am not familiar with RPi or Python.
Cheers Bob

1 Like

Hi Bob,

Either 82992 or 828992 did jump out as rather odd numbers to me as well. So my first thought was to wonder if this was a case of a maximum value for a given variable type somewhere in the code.
I think python should handle any value gracefully in theory, but I won’t rule out running into a limitation of a library where we’re just asking for a number too big for a function that is expecting an integer and that’s why we’re getting errors.