Arduino OV7670 Camera Code Example, Library, Wiring Diagram

In this tutorial, you’ll learn how to interface an Arduino With OV7670 Camera Module, install the Arduino OV7670 library, and test some Arduino code examples to capture static images and live videos using the OV7670 camera.

Table of Contents

  1. Arduino OV7670 Camera Interfacing
  2. Arduino OV7670 Library Installation
  3. Arduino OV7670 Code Example (Video Capture)
  4. Arduino OV7670 Code Example (Image Capture)
  5. Wrap Up

Arduino OV7670 Camera Interfacing

The OV7670 is a low-cost image sensor module that captures photos and videos up to 30 FPS. It is popular for DIY electronics projects like surveillance systems, robotics vision, or image-based applications. Ideally, you’d want a more powerful microcontroller board than an Arduino UNO (Atmega328p running @ 20MHz).

Boards like (Arduino Nano 33 BLE, ESP32, RP2040W) are all better suited for such application and all of them are IoT-capable boards making it easier to stream the camera’s data for a lot more possibilities.

However, in this tutorial, we’ll be interfacing the OV7670 camera with an Arduino UNO and sending the image frames over serial UART to a PC application where we’ll view the captured images/videos.

OV7670 Camera

OV7670 Camera Module

The OV7670 camera module is a CMOS camera sensor capable of capturing images in RGB565 or YUV422 formats, which are ideal for microcontroller-based systems. However, interfacing the OV7670 with an Arduino UNO is a bit challenging due to the camera’s high data rate and lack of buffer memory to store the image frames.

Key Specifications of OV7670 Camera Module:

  • Resolution: Up to 640×480 (VGA)
  • Pixel Format: RGB565, YUV422
  • Interface: 8-bit parallel data bus
  • Operating Voltage: 3.3V
  • Frame Rate: Up to 30 FPS (frames per second)

Buy an OV7670 Camera: you can find it here on ( Amazon, AliExpress, eBay )

Arduino OV7670 Wiring (Connection Diagram)

This is a summary of the connections needed between your Arduino UNO board and the OV7670 camera module.

OV7670Arduino UNODescription
VCC3.3VPower supply
GNDGNDGround
SIOC (SCL)A5 (I2C Clock)Serial Clock Line (SCL)
SIOD (SDA)A4 (I2C Data)Serial Data Line (SDA)
VSYNCD2Vertical Synchronization
HREFNo ConnectionHorizontal Synchronization
PCLKD12Pixel Clock
XCLK (MCLK)D3External Clock Input (D3 output is level-shifted to 3.3v with voltage divider resistors)
D0-D3A0-A3Parallel 8-bit Data Pins (0->3)
D4-D7D4-D7Parallel 8-bit Data Pins (4->7)
RESET3.3VReset
PWDNGNDPower Down

Here is the connection (wiring) diagram for the OV7670 Camera with Arduino UNO board.

Arduino OV7670 Camera Connection Wiring Diagram

❕ Note

The OV7670 Camera Module’s Pin (MCLK) is also referred to as (XCLK). This signal needs to be level-shifted from 5V down to 3.3V, which could be easily achieved with a voltage divider resistor network (3.3k and 4.7k) as shown in the circuit connection diagram above.


Arduino OV7670 Library Installation

The library we’ll use in this tutorial is called CameraOV7670, and this is how to install it on your system.

Step #1

Download the library folder from the attached zip file linked at the end of this tutorial.

Step #2

Copy the CameraOV7670 folder to your Arduino libraries directory. Which is usually under:

And that’s all about it. Now we can use the library as we’ll do in the next two example projects.


Arduino OV7670 Code Example (Video Capture)

In this example project, we’ll capture video footage using Arduino UNO and the OV7670 camera module. The video frames are sent to our PC over serial port and a Java Application is used on the PC side to display the incoming image frames.

The wiring diagram for this example project is shown earlier in this tutorial. It’s better to re-check it again and go through the connections table one by one. However, I’ll show you the setup on my test bench. Soldering some connectors on a perfboard would make this look a bit more cleaner TBH.

Arduino OV7670 Camera Example

Example Code

Here is the full code listing for this example.

Note that the OV7670_UART.h header file is used to configure this demo application. By modifying the number in one line of code in that file, you can try different operating modes. In this demo example, I’ve used the (320×240 RGB @ 500kbps baud rate) Mode #5. Here are the other options that you can select from that header file:

PC App

In the attached download zip folder, you’ll also find a PC application (ArduImageCapture) that has 3 batch executables for (Windows, Linux, and Mac). Run the appropriate version according to your system’s OS. Select the Arduino board’s COM Port and Baud Rate, and click on the “Listen” button to start capturing the image data coming from the Arduino board & the OV7670 camera.

Arduino OV7670 Camera Example Image

Testing Results

Here is the result of testing this project code example on my Arduino UNO board.

❕ Note

Any shaking in the camera’s position will result in severe image distortion as you might have noticed in the video shown above which I’ve captured while holding the camera module in my hand and pointing it to different objects on my test bench.


Arduino OV7670 Code Example (Image Capture)

In this example project, we’ll capture images using Arduino UNO and the OV7670 camera module. The images are sent to our PC over the serial port and a Java Application is used on the PC side to display the incoming image frames.

The wiring diagram for this example project is the same as before, just add a push button and hook it up to Arduino’s Pin 8.

Example Code

Here is the full code listing for this example.

Testing Results

Here is the result of testing this project code example on my Arduino UNO board. Upon each button press event, an image is captured with the OV7670 camera and sent over the serial port to the PC application. Just like the previous example project, but it’s not automatically/continuously capturing and sending image frames. Instead, this demo example captures a single shot image upon button press event.

Arduino OV7670 Camera Example Image Capture
Captured an image for a portion of my test bench

Required Parts List

Here is the full components list for all the parts you’d need to perform the practical LABs mentioned in this tutorial and the whole Arduino Programming series of tutorials found here on our website.

* Please, note that those are affiliate links and we’ll receive a small commission on your purchase at no additional cost to you, and it’d definitely support our work.

QTY.Component NameAmazon.comAliExpresseBay
1OV7670 CameraAmazonAliExpresseBay
1Arduino UNO KitAmazonAliExpresseBay
1Complete Arduino Sensors/Modules KitAmazonAliExpresseBay
1DC Power SupplyAmazonAliExpresseBay
1BreadBoardAmazonAliExpresseBay
1LEDs KitAmazonAmazonAliExpresseBay
1Resistors KitAmazonAmazonAliExpresseBay
1Capacitors KitAmazonAmazonAliExpress & AliExpresseBay & eBay
1Jumper Wires PackAmazonAmazonAliExpress & AliExpresseBay & eBay
1Push ButtonsAmazonAmazonAliExpresseBay
1PotentiometersAmazonAliExpresseBay

★ Check The Links Below For The Full Course Kit List & LAB Test Equipment Required For Debugging ★

Download Tutorial’s Attachments

You can download all attachment files for this Article/Tutorial (project files, schematics, code, etc..) using the link below. Please consider supporting our work through the various support options listed in the link down below. Every small donation helps to keep this website up and running and ultimately supports the whole community.


Wrap Up

To conclude this tutorial, we’ve covered how to interface an OV7670 camera with an Arduino UNO, and capture images and videos with this camera module. You can build on top of the provided example projects and use the OV7670 camera with your Arduino boards.

If you’re just getting started with Arduino, you need to check out the Arduino Getting Started [Ultimate Guide] here.

And follow this Arduino Series of Tutorials to learn more about Arduino Programming.

References:

Share This Page With Your Network!
Join Our +25,000 Newsletter Subscribers!

Stay Updated With All New Content Releases. You Also Get Occasional FREE Coupon Codes For Courses & Other Stuff!

Photo of author
Author
Khaled Magdy
Embedded systems engineer with several years of experience in embedded software and hardware design. I work as an embedded SW engineer in the Automotive & e-Mobility industry. However, I still do Hardware design and SW development for DSP, Control Systems, Robotics, AI/ML, and other fields I'm passionate about.
I love reading, writing, creating projects, and teaching. A reader by day and a writer by night, it's my lifestyle. I believe that the combination of brilliant minds, bold ideas, and a complete disregard for what is possible, can and will change the world! I will be there when it happens, will you?

Leave a Comment