Capture Images Using ArduCam OV2640 Camera Module and ESP32 Hardware
This example shows how to capture JPEG images using the ArduCam OV2640 camera module with ESP32 hardware.
Required Hardware
To run this example, you need the following hardware:
ArduCam OV2640 camera module
ESP32 board
Hardware Connection
Connect these pins on the OV2640 camera module and the ESP32 board:
CS/SS to 5
SDI to 23
SDO to 19
SCK to 18
SDA, SCL, 5V, and GND pins on the OV2640 camera module to respective pins on the ESP32 board.
Simulink Model
Open the arduino_ov2640camera_imagecapture
Simulink® model included with this example.
In this example, you trigger the image capture by using a pulse generator. You can replace the pulse generator with a constant block. When the output at the Status port in the OV2640 Camera Sensor block is 0, indicating a valid image capture. The Enabled subsystem block in the Transmit image over Serial subsystem sends image data over the serial port 0 on the ESP32 board.
Configure and Deploy Simulink Model
1. On the Hardware tab on the Simulink toolstrip, click Hardware Settings to open the Configuration Parameters dialog box.
2. In the Hardware Implementation pane, select your ESP32 board from the Hardware board parameter drop-down list.
3. In the Hardware board setting section, click Target hardware resources. Under Host-board connection, specify the port number of the port to which you connected your ESP32 board in the Host COM Port parameter. You can use the default baud rate of 921600 or change it according to your requirement. Click OK.
4. On the Hardware tab of the Simulink model, in the Deploy section, click Build, Deploy & Start to run this model on the ESP32 board. The model sends the buffered raw JPEG image data to serial port 0 on the ESP32 board.
View Captured Image
To display the image captured from the OV2640 camera module in a MATLAB® Figure window, open the jpegimageconstruct.m
file attached with this example. Specify the COM port number and baud rate in the file, place the object in front of the camera, and then run the code. Specify the same COM port number and the baud rate as the Simulink model. The jpegimageconstruct
function reads raw image data frames from the camera sensor module and coverts them to JEPG files. You can view the JPEG image in the figure window in real time.