CircuitPython's espcamera module is available on most supported ESP32-S2 and ESP32-S3 boards with PSRAM. It incorporates both the camera configuration code and the image capturing code in a single library that works across multiple types of camera modules, instead of being available for regular CircuitPython objects.

Setting 'reserved PSRAM'

Because of how CircuitPython and ESP-IDF (Espressif IoT Development Framework) manage memory together, a portion of memory has to be set aside for the camera framebuffers.

Usually, 1MB (1048576 bytes) is a reasonable amount of memory to reserve. This is plenty of space for two 320×240 bitmap images or a 5-megapixel JPEG image, along with other memory that the esp-idf allocates internally.

Boards with built-in cameras include a default reserved PSRAM setting. Boards with only a dedicated camera header do not.

To set the reserved memory amount, edit the settings.toml file within the CIRCUITPY drive. Add a line that says CIRCUITPY_RESERVED_PSRAM=1048576

The setting will become effective when the board is reset with the reset button. You can check it by opening the repl and running the following lines:

Adafruit CircuitPython 8.0.0-rc.1 on 2023-01-30; Kaluga 1 with ESP32S2
>>> import espidf
>>> espidf.get_reserved_psram()
1048576

Pin Choices

By selecting appropriate pins, you can use the espcamera CircuitPython module on other boards with supported ESP32, ESP32-S2 and ESP32-S3 microcontrollers:

  • xclk, pclk, vsync, href: Free choice of any pin
  • reset, shutdown: Free choice of any pin. Can omit one or both, but the initialization sequence is less reliable.
  • data_pins: Free choice of any 8 pins

By convention, if a board has an integrated camera or a dedicated camera connector, the following will exist in the board module:

  • CAMERA_SIOC - the SCL pin of the camera
  • CAMERA_SIOD - the SDA pin of the camera
  • CAMERA_PCLK - the pixel clock of the camera
  • CAMERA_VSYNC - the vertical sync of the camera
  • CAMERA_HREF - the horizontal sync of the camera
  • CAMERA_XCLK - the input clock pin of the camera
  • CAMERA_DATA - the 8 data pins of the camera

Continue to the next page to see how to use the camera module with the Espressif Kaluga, which has a compatible 18-pin camera connector built in.

This guide was first published on Feb 21, 2023. It was last updated on Feb 21, 2023.

This page (Espressif ESP32-family Overview) was last updated on Feb 21, 2023.

Text editor powered by tinymce.