OV7670 Arduino Camera Sensor Module Framecapture Tutorial

256,959

157

125

Introduction: OV7670 Arduino Camera Sensor Module Framecapture Tutorial

Description

The camera module is powered from a single +3.3V power supply. An external oscillator provide the clock source for camera module XCLK pin. With proper configuration to the camera internal registers via I2C bus, then the camera supply pixel clock (PCLK) and camera data back to the host with synchronize signal like HREF and VSYNC. The OV7670 camera module is a low cost 0.3 mega pixel CMOS color camera module, it can output 640x480 VGA resolution image at 30fps. The OV7670 camera module build in onboard LDO regulator only single 3.3V power needed and can be used in Arduino, STM32,Chipkit, ARM, DSP , FPGA and etc.

Specification

  • Optical size 1/6 inch
  • Resolution 640x480 VGA
  • Onboard regulator, only single 3.3V supply needed
  • Mounted with high quality F1.8 / 6mm lens
  • High sensitivity for low-light operation
  • VarioPixel® method for sub-sampling
  • Automatic image control functions including: Automatic
  • Exposure Control (AEC), Automatic Gain Control (AGC), Automatic White Balance (AWB), Automatic
  • Band Filter (ABF), and Automatic Black-Level Calibration (ABLC)
  • Image quality controls including color saturation, hue, gamma, sharpness (edge enhancement), and anti-blooming
  • ISP includes noise reduction and defect correction
  • Supports LED and flash strobe mode
  • Supports scaling
  • Lens shading correction
  • Flicker (50/60 Hz) auto detection
  • Saturation level auto adjust (UV adjust)
  • Edge enhancement level auto adjust
  • De-noise level auto adjust

Step 1: Material Preparation

In this tutorial, you will need :

1. Arduino Uno Board and USB
2. OV7670 Arduino Camera Sensor Module STM32
3.10K resistor X 2
4. 4.7K Resistor X2
5. Breadboard

and you will be using Arduino IDE and Java.

Step 2: Pinout Connection

Connect your circuit as illustrated on the picture above.

Step 3: Java

You have to download this to be able to interface this camera sensor module on your pc.Open the zip file and install to your computer. By default, this will be install to your c drive in your program files folder. As for mine, it is stored in C:\Program Files\Java\jdk1.8.0_74. You can refer picture above.

NOTE : This jdk-8u74-windows-i586.rar file is quite big.

Step 4: Sample Source Code

This sample source code is originally from this link. Download this sample source code, open it on your Arduino IDE, connect your Arduino Uno Board to your computer and upload it. Select the correct board and port before uploading this source code. Refer image above for help.

NOTE : Don't mind that it does not recognize some libraries in the beginning of the file. If it bothers you, comment the whole line out with //

Step 5: Checking Your Port

Find out what USB port your Arduino is connected to, something like COM4 or COM5. You could check it on your Control Panel > Device Manager > Ports (COM & LPT) > right click > Properties > Port Settings > Advanced > COM Port Number > /Select Your Port Number/. You can refer the image above for help. As for mine, it is port COM5.

Step 6: Com_#.rar

Depending on what port number your Arduino is connected to, download the corresponding file. COM1 = com_1.rar , COM2 = com_2.rar and etc. Open your com#.rar on WinRaR, extract/copy the 'code' folder from com_#.rar, go to Local Disk > Program Files > Java > jdk1.8.0_74 > bin and paste it there. you can refer the picture above for a better understanding.

Step 7: C:\out

You have to create a new folder on your c drive / Local Disk (C:). This will be your camera module sensor's taken picture's destination. Name this folder as out (it could be anything though).

Step 8: Extra.rar

1. Download and extract the Extra.rar file below and open it. As you could see, there is src folder, lib folder and "win32com.dll". You have to copy and placed "win32com.dll" in the "C:\Program Files\Java\jdk1.8.0_74\jre\bin" directory.

2. Then, open the lib and you could see the "comm.jar" and "javax.comm.properties" in it. Copy and paste the "comm.jar" in "C:\Program Files\Java\jdk1.8.0_74\jre\lib\ext" and "javax.comm.properties" in the "C:\Program Files\Java\jdk1.8.0_74\jre\lib" directory.

NOTE : it may ask for administrator permission, just proceed anyway.

Step 9: CMD

Open cmd and open the folder wherein the code folder is by writing its address. mine is "C:\Program Files\Java\jdk1.8.0_74\bin". Click enter and it will give u "C:\Program Files\Java\jdk1.8.0_74\bin>". Now, write "java code.SimpleRead". It supposed to be like this---> C:\Program Files\Java\jdk1.8.0_74\bin>java code. SimpleRead. You can refer image for help.

Step 10: Result

You can see the picture taken from your OV7670 Camera Module Sensor in your our folder in c drive.

Step 11: Troubleshooting

1. If your cmd cannot find images, try switching the USB of the arduino from a USB2.0 to a USB3.0 (blue socket) or vice versa.

2 If you receive scrambles pictures, you need to edit the sample source code. Edit line: wrReg(0x11, 12); try changing the 12 to 11/10/9/13. Upload it to the arduino and run the cmd code again.

22 People Made This Project!

Recommendations

  • Digital Fabrication Student Design Challenge

    Digital Fabrication Student Design Challenge
  • Pets Challenge

    Pets Challenge
  • Fruits and Veggies Speed Challenge

    Fruits and Veggies Speed Challenge

125 Comments

0
jscanova
jscanova

Question 7 weeks ago on Step 2

Forgive my ignorance, but how are the resistor values calculated?

0
maxsrobotics
maxsrobotics

Question 1 year ago

I am having a problem: I am recieving scambles ans static pics, and I have changed wrReg(0x11, 12) to the examples above. here is an image of one of my imgs:

Edit: I fixed it :)

BadIMG.PNG
0
Wissam
Wissam

Answer 2 months ago

How did you slove the problem?

0
omerkati99
omerkati99

Answer 5 months ago

How did you solve it? I have the same problem

0
Bowserinator
Bowserinator

Tip 6 months ago

Some tips:
Your model might label VSYNC as VS, HREF as HS, and XCLK as HCLK

If the 1MHz BAUD rate is too fast for you, you CAN change it:

1. Change this line to whatever the comment says
UBRR0L = 1; //0 = 2M baud rate. 1 = 1M baud. 3 = 0.5M. 7 = 250k 207 is 9600 baud rate.
2. In setup(), multiply the 2nd number in this line (the 10):
writeReg(0x11, 10);
by whatever multiple you slowed it down by. For example, if you changed the BAUD rate from 1M to 500k, you take 10 * 2 = 20 as 500k is 2 times slower.

Explanation: The Arduino is too slow to provide a clock, so this uses the camera's internal clock set to the right speed to match the BAUD rate. Thus if you reduce the BAUD rate you need to slow down the clock accordingly. The 0x11 register is the prescaler for the camera's internal clock, basically CLK = [camera clock speed] / [the value in the 0x11 register]. (There might be a +1 somewhere in there)


Here's also a python program to display the read image:
https://pastebin.com/du8DxiRH

You can adjust the port more easily and you don't need to do weird hacks to get the java serial reader.

0
mantraxyz
mantraxyz

1 year ago

Guys, I follow the code instructions, this "c:\Program Files (x86)\Java\jre1.8.0_74\bin>java code.SimpleRead
Port name: COM5
Looking for image"

But no images I get on C:\out folder, I change com port, I use the suggested java version, and change from usb port from one to another. ¿is something else not in this code to make this work?, the resistors need to be the correct or just protect the circuit?.
I have no errors..

0
ArchWik
ArchWik

Reply 8 months ago

I had the same problem I changed one resistor to another with greater tolerance and now it works.

0
pepo939393
pepo939393

Reply 11 months ago

I have the same problem. Did you fix it?

0
Momina___1999
Momina___1999

Reply 1 year ago

There's the problem in connection(hardware) for sure

0
theAkash2509
theAkash2509

Reply 1 year ago

Can you please check once... in cmd instruction it is jdk1.8.0_74 not jre.... I am not sure maybe this is causing you the problem....

0
athosmba25
athosmba25

Question 8 months ago

In the project it doesn't say how we choose where the images will be saved, it just says that we must create a folder for that purpose.<br>
0
rahat21mishwani
rahat21mishwani

9 months ago

Hell there
i tried this code and follow each step but still having error in Comport Selection,,,
i change port from com5 to 4 and download file for com4 and place it in bin and uplad the code but same error....
please help!!!!!

error with com4 at Arduino IDE.JPGerror with com4.pngError with com5.png
0
Momina___1999
Momina___1999

1 year ago

I'm having issue in CMD, if anyone can help me please do so.

aaa.JPG
0
ryan.avery.dev
ryan.avery.dev

4 years ago

I made it last night. I already had JDK installed b/c im a software developer but I had the 64bit JDK so when I did the instructions step by step and then tried to run the jar, it said something like "cannot run 32bit dll in 64 bit environment" so I got the 32 bit version of the latest jdk (just google "jdk 32 bit download" and then click first link. Then download the first one that says windows x86 and install that when it finishes downloading. Then you need to re-do this tutorial and any time he says "Program Files" you need to replace that with "Program Files (x86)" and then it should work.

7.bmp
0
HassanG29
HassanG29

Reply 3 years ago

Did you use usb 2.0 or 3.0? May laptop doesn’t have usb 3 and its stuck at looking for images....

Please respond

Thanks in advance

0
Sujitg8
Sujitg8

Reply 3 years ago

but it says looking for image not going beyond that. please suggest something. i have cleared all errors but im stick here

Untitled.jpg
0
dhivakar183
dhivakar183

Reply 3 years ago

How to clear my problem