Go Down

Topic: OV7670 - Without FIFO - Reading Snapshot from Arduino (Read 2 times) previous topic - next topic


Dear All,

I know that there is a lot in internet about OV7670 and I read a lot about it, but seems something is missing.

First of all I took a look into the way how can we read pixel by pixel from the camera to build the rectangular 600 X 480 image, and this was quite easy to understand considering HREF, VSYNCH and PCLOCK described on documentation here: http://www.voti.nl/docs/OV7670.pdf. I understand XCLOCK as an input I need to give to OV7670 as a kind of cycle controller and RESET would be something to reset it.

So at this point I thought that the functionality of such camera would be covered by wiring the following pins:

D0..D7for data (pixel)connected to arduino digital pins 0 to 7as INPUT on arduino board
XCLKfor camera clockconnected to arduino digital pin 8as OUTPUT from arduino board
PCLKfor pixel clockconnected to arduino digital pin 9as INPUT on arduino board
HREFto define when a line starts / endsconnected to arduino digital pin 10as INPUT on arduino board
VSYCHto define when a frame starts / endsconnected to arduino digital pin 11as INPUT on arduino board
GRDgroudconnected to arduino GRD
3V33,3 INPUTconnected to arduino 3,3v
RESETconnected to arduino RESET
PWDNconnected to arduino GRD

The implementation for such approach from my point of view would be something like:
Code: [Select]

for each loop function do
   write high to XCLK

   if VSYNCH is HIGH

   if HREF is LOW

   if lastPCLOCK was HIGH and currentPCLOCK is LOW

end for

My readPixelFromDataPins() basically read just the first byte (as I'm just testing if I can even read something from the camera), and it is written as follows:

Code: [Select]

byte readPixelFromDataPins() {
  byte result = 0;
  for (int i = 0; i < 8; i++) {
    result = result << 1 | digitalRead(data_p[i]);
  return result;

In order to check if something is being read from the camera I just print it to the Serial 9600, the byte read from data pins as a number. But currently I'm receiving only zero values. The code I'm using to retrieve an image is stored here: https://gist.github.com/franciscospaeth/8503747.

Did somebody that makes OV7670 work with Arduino already figure out what am I doing wrong? I suppose I'm using the XCLOCK wrongly right? What shall I do to get it working?

I searched a lot and I didn't found any SSCCE (http://sscce.org/) for this camera using arduino, if somebody have it please let me know.


Hi Riva,

Thanks for your quick response. I alredy read the topic before implementing it and it isn't clear how to proceed since it doesn't comment how XCLK is handled. I alredy tried to use the infos from there but is somehow messy to grab all needed things to test it.

Have you alredy implemented somethong with ov7670? Would you be able to provide a minimal working sampl for it?



XCLK is easy to generate just use PWM to generate an 8mhz clock. No need to mess with fuse bits or anything The AVR hardware has a mode of PWM that lets you output frequencies using this formula F_CPU/((x+1)*2).


Have you alredy implemented somethong with ov7670? Would you be able to provide a minimal working sampl for it?

Though I have both versions (FIFO  & non FIFO) of this camera I have not got round to doing anything with them yet so no sample code for you.  :(


I have provided a lot of sample code. You can read my long thread the link was posted above.


Hi Mr. Arduino,

I saw you had a repository associated to your answer, the problem is I'm a bit confusing what is really necessary to run the snapshot of ov7670 and what is code from other stuff. My idea is get an SSCCE for the camera.

You commented I can generate the frequency using a PWM, which one may I use? Is there a schematic or reference therefore?

Thanks for your support!


Hi Francisco:
I've been working with the OV7670 camera for a few days and I've reached to a code very similar to yours, except that I'm trying to use an external CLK of 20MHz connected to XCLK, but I liked the idea of using a PWM (I just read it).
The main issue in information and all the libraries I've found is that in all of them  they have a SHIELD or a GLCD connected to the camera, and I just have the camera sensor.
About this line you posted
   if last PCLOCK was HIGH and current PCLOCK is LOW
I was thinking in connecting the PCLOCK as an external interrupt. The code in setup would be: attachinterrupt(2,clock,RISING); (interrupt 2 is connected to PIN 0 in my Arduino Leonardo).
I'm also having problems in the I2C communication.  When I use the function "Wire.endTransmission()" it returns 2, that means that the acknowledge was not received.
Please, if you have reached to any solutions let me know, I would appreciate it.
Sorry for my English and thanks.


Hello francisco-spaeth,
If you still want to find solution to run OV7670 I propose to collaborate in order to get an SSCCE.
I tried to find some support on thread of Mr. Arduino several months ago in order to create SSCCE but it was not easy.
Also, I wrote email to Shenzhen LC Technology Co., Ltd. who is the producer of my ov7670. They provided me some materials which I also can't process due to poor comments in the code/documentation, usage of LCD, SD card, etc which I'm not planning to use.
Documents are here: https://www.dropbox.com/s/2xv0bn9lepqmsjy/OV7670%20module.rar


Hello, Francisco Spaeth you managed to solve the problem? Because I'm having the same problem.

"// not used int siod = 12;
// not used int sioc = 13;"  don't need???

Go Up