I2c always reads as 255

I currently have an ov7670 interfaced with an arduino mega. I have disabled the internal pullups by editing the wiring library (the ov7670 uses 3.3v) and have tried both a 1k and a 10k pullup resistor.By removing the 3.3v it gets stuck on Wire.endTransmission(true); the ov7670 uses SCCB which should be compatilbe with i2c Here is my code

#include <Wire.h>
void setup()
  pinMode(13, OUTPUT);
  Serial.println("I2C started");
  Wire.requestFrom(0x21, 1,true);
  //while (!Wire.available()) {}
  unsigned char x=Wire.read();
void loop()

What pin numbers are you using on your mega to wire to the I2C device? The mega uses different pin numbers then the 328p based boards for I2C.


20 and 21 they are labeled SDA and SCL so I used those. It must be plugged in correct because when I remove power to the ov7670 It gets stuck at Wire.endTransmission(true); also when I uncomment while (!Wire.available()) {} it gets stuck there. Could 255 just be an error message?
Here is a picture if that will help.(click for larger)

Edit: I did a google search and it turns out that someone is having a similar issue http://www.mentby.com/dave-hylands/i2c-read-fails-but-write-works.html
Should I make a program that bitbangs sccb read?

It's been quite a while sense I played with I2C, but I seemed to recall the a 255 return is what I would get if there was no response back from the device, for instance if you are sending the wrong device address for the attached device, or the device has no power applied. There is frequently addressing problems when dealing with 8 bit address some vendors refer to Vs the 7 bit address (no low order read/write bit sent) that the I2C library requires you to use.

Good luck;


Hi there,

You might want to try this library : http://dsscircuits.com/articles/arduino-i2c-master-library.html

It includes a scan function which can be very handy, I had a similar problem with an LCD panel the address supplied was not the address the device was actually set to.

The Scan function automatically prints to the serial monitor.

#include <I2C.h>

#define SD21 0x61

int x = 0;
int y = 0;
int z = 0;
int err_c = 0;

unsigned int ServoHigh, ServoLow; 
unsigned int Servo_pos = 0;

void setup()
  //configure device for continuous mode

void loop()
  delay(3000); //give us time to open serial monitor
  // display I2C bus address info
  for (int i=0;i<1;i++)

There is a I2C scanner here - http://www.gammon.com.au/forum/?id=10896 - search for I2C scanner (about 80% near the end)

Both scanners say no devices found. I am going to write a bit-bang sccb function. How would I convert 5v to 3.3v (bit bang is not open drain like i2c) I only have some hex buffers and resistors do I need to buy a bi-directional level shifter?

Mr_arduino: I am going to write a bit-bang sccb function. How would I convert 5v to 3.3v (bit bang is not open drain like i2c)

Your bit-bang function better be open drain if you want it to be I2C compatible. The way to do this is to toggle the SCL/SDA pins between output low and input mode. Logic high (pin mode input) is then limited to your external pullup voltage.