Getting Started With the OV7670 Camera for Arduino

One of the most exciting projects with an Arduino is giving the project its own eyes, so to speak. Adding a camera to an Arduino project opens up a broad list of applications, such as monitoring and surveillance systems. In this Learn article, we will be introducing the OV7670 VGA camera, showing how to interface the module with an Arduino Uno, and demonstrating how to open the captured image.

OV7670 Camera

The OV7670 Camera is a VGA camera with an optical lens size of 1/6 inch. The module can be powered with a +3.3V power supply. It can output an image with a resolution of 640×480 and a video rate of 30 fps VGA. For more details on the module, visit Twins Chip’s product page, found here.

Materials Needed

  • OV7670 Camera Module
  • Arduino Uno
  • Set of Jumper Wires
  • USB Type B for Arduino Uno
  • 2 x 10k Ohms Resistor
  • 2 x 4.7k Ohms Resistor
  • 1 x Breadboard

Pin Configuration

First, we should look at the pin configuration of the OV7670 Camera to better understand how to interface it with the Arduino Uno. Below is the table of pins and their functions.

Pin NamePin TypeDescription
VDDSupplyPower Supply
GNDSupplyGround Level
SDIOCInputSCCB Clock
SDIODInput/OutputSCCB Data
VSYNCOutputVertical Synchronization
HREFOutputHorizontal Synchronization
PCLKOutputPixel Clock
XCLKInputSystem Clock
D0-D7OutputVideo Parallel Output
RESETInputReset (Active Low)
PWDNInputPower Down (Active High)
Pin Configuration and Description

Wiring Diagram

Our next step would be to connect the OV7670 Camera module to the Arduino Uno. With the use of the breadboard, wire the two components with the needed resistors as shown.

See also  Automating Shell Scripts and Python Programs Using CRON

And with that, we are ready to test out the camera.

Programming Arduino Uno

When programming the Arduino Uno to interface with the OV7670 Camera, we first have to include a couple of libraries. The OV7670 Camera utilizes an I2C interface, which means the library is needed. Here is the list of libraries required:

  • <stdint.h>
  • <avr/io.h>
  • <util/twi.h>
  • <util/delay.h>
  • <avr/pgmspace.h>

Some of the important functions in the code are:

  • arduinoUnoInut(); // Placed in Setup(), this function initializes the Arduino Uno
  • setResolution(); // Selects the resolution for the QVGA image that will be taken
  • setColor(); // sets the register values that would be used to define the color mode.
  • writeReg(0x11, 10); // the write-to-register function, which is in hex values.
  • captureImg(320, 240); // Function to get the image resolution size.

To download the sample code, click here.
Compile and upload the code to the Arduino Uno.

Serial Port Reader

Lastly, we need to be able to fetch the data and display it. We need to use a simple GUI called Serial Port Reader to do this. You can download the file here. Run the file and follow the steps below.

1. Run Serial Port Reader

2. Connect the Arduino Uno to the PC via USB Port and select the Serial port that the Arduino is designated in.

3. Click on “Start” to begin serial read.

4. Save images by clicking on “Save picture”.