API Reference

adafruit_ov5640

CircuitPython driver for OV5640 Camera

  • Author(s): Jeff Epler

Implementation Notes

Hardware:

Software and Dependencies:

class adafruit_ov5640.OV5640(i2c_bus: busio.I2C, data_pins: List[Pin], clock: Pin, vsync: Pin, href: Pin, shutdown: digitalio.DigitalInOut | None = None, reset: digitalio.DigitalInOut | None = None, mclk: Pin | None = None, mclk_frequency: int = 20000000, i2c_address: int = 60, size: int = 1, init_autofocus: bool = True)

Control & Capture Images from an OV5640 Camera

Parameters:
  • i2c_bus (busio.I2C) – The I2C bus used to configure the OV5640

  • data_pins (List[microcontroller.Pin]) – A list of 8 data pins, in order.

  • clock (microcontroller.Pin) – The pixel clock from the OV5640.

  • vsync (microcontroller.Pin) – The vsync signal from the OV5640.

  • href (microcontroller.Pin) – The href signal from the OV5640, sometimes inaccurately called hsync.

  • shutdown (Optional[digitalio.DigitalInOut]) – If not None, the shutdown signal to the camera, also called the powerdown or enable pin.

  • reset (Optional[digitalio.DigitalInOut]) – If not None, the reset signal to the camera.

  • mclk (Optional[microcontroller.Pin]) – The pin on which to create a master clock signal, or None if the master clock signal is already being generated.

  • mclk_frequency (int) – The frequency of the master clock to generate, ignored if mclk is None, requred if it is specified. Note that the OV5640 requires a very low jitter clock, so only specific (microcontroller-dependent) values may work reliably. On the ESP32-S2, a 20MHz clock can be generated with sufficiently low jitter.

  • i2c_address (int) – The I2C address of the camera.

  • size (int) – The captured image size

  • init_autofocus (bool) – initialize autofocus

autofocus() list[int]

Perform an autofocus operation.

If all elements of the list are 0, the autofocus operation failed. Otherwise, if at least one element is nonzero, the operation succeeded.

In principle the elements correspond to 5 autofocus regions, if configured.

autofocus_init()

Initialize the autofocus engine from ov5640_autofocus.bin

autofocus_init_from_bitstream(firmware: bytes)

Initialize the autofocus engine from a bytestring

autofocus_init_from_file(filename)

Initialize the autofocus engine from a .bin file

property autofocus_status

Read the camera autofocus status register

property autofocus_vcm_step

Get the voice coil motor step location

property brightness: int

Sensor brightness adjustment, from -4 to 4 inclusive

capture(buf: bytearray | memoryview) None

Capture an image into the buffer.

Parameters:

buf (Union[bytearray, memoryview]) – A WritableBuffer to contain the captured image. Note that this can be a ulab array or a displayio Bitmap.

property capture_buffer_size: int

Return the size of capture buffer to use with current resolution & colorspace settings

property colorspace: int

Get or set the colorspace, one of the OV5640_COLOR_ constants.

property contrast: int

Sensor contrast adjustment, from -3 to 3 inclusive

deinit() None

Deinitialize the camera

property effect: int

Get or set the special effect, one of the OV5640_SPECIAL_EFFECT_ constants

property exposure_value: int

Sensor exposure (EV) adjustment, from -3 to 3 inclusive

property flip_x: bool

Get or set the X-flip flag

property flip_y: bool

Get or set the Y-flip flag

property height: int

Get the image height in pixels.

property mclk_frequency: int | None

Get the actual frequency the generated mclk, or None

property night_mode: bool

Enable or disable the night mode setting of the sensor

property quality: int

Controls the JPEG quality. Valid range is from 2..54 inclusive

property saturation: int

Get or set the saturation value, from -4 to +4.

property size: int

Get or set the captured image size, one of the OV5640_SIZE_ constants.

property test_pattern: bool

Set to True to enable a test pattern, False to enable normal image capture

property white_balance: int

The white balance setting, one of the OV5640_WHITE_BALANCE_* constants

property width: int

Get the image width in pixels.