OpenMV H7 Plus Overexposed Photos

I am using an OpenMV H7 Plus camera to remotely transfer photos. Most of the time, the camera returns photos that look great, but occasionally, it returns an entire series of photos that appear to be extremely overexposed. Any ideas of how this can be corrected? Sometimes, an entire series of images is almost completely white and few details in the images can be recognized.

Here is the script that I’m using:

import sensor
import ustruct
from machine import Pin
from pyb import USB_VCP
pin1 = Pin("P9", Pin.OUT)
usb = USB_VCP()
sensor.reset()
sensor.set_pixformat(sensor.RGB565)
sensor.set_framesize(sensor.QXGA)
sensor.set_framebuffers(1)
sensor.skip_frames(time=2000)
sensor.set_auto_exposure(False, exposure_us=25000)
pin1.value(True)
while True:
    cmd = usb.recv(4, timeout=5000)
    if cmd == b"snap":
        img = sensor.snapshot()
        img = img.to_jpeg()
        usb.send(ustruct.pack("<L", img.size()))
        usb.send(img)
        sensor.flush()

You might want to turn off auto_gain also. That will continue to run even if auto exposure is off. Also, auto white balance. Both of those will kick in to try to increase the image brightness if it’s less than the target value.