I2C isn't working properly with my sensor

Hi there

I've been trying to get my ov7670 camera to work with arduino.
(For those of you who know the sensor) I've been applying a clock signal to XCLK, powering 3v3 and RST with the arduino 3v3, GND and PWDN with the arduino GND and I've attached the arduino and ov7670 i2c pins to a level shifter (the ov7670 uses a 3v3 i2c instead of a 5v).

I've used an i2c scanner and I find if I scan a few times the device might appear once or twice.
I wrote some code to read registers from the device, and it occasionally works:

      Wire.beginTransmission(0x21);
      Wire.write(0x01);
      endput = Wire.endTransmission();
      Serial.print(endput); Serial.print("_");
    delay(25);          
     Wire.requestFrom(0x21,1);
     output=Wire.read();
     Serial.print(output); Serial.print("_");
    delay(200);

However, when I try and write to the registers it fails.

      Wire.beginTransmission(0x21);
      Wire.write(0x01);
      Wire.write(0x11);
      endput = Wire.endTransmission();
      Serial.print(endput); Serial.print("_");
    delay(25);          
     Wire.requestFrom(0x21,1);
     output=Wire.read();
     Serial.print(output); Serial.print("_");
    delay(200);

I've tried 10k pull up resistors (with and without the wire internal pullups disabled) and still failed to write to registers, although I can read the registers occasionally.

Does anyone know what might be going on with my sensor? :slight_smile:

I2C should not require a level shifter.
The arduino should only pull the line low, never pull it high. So you can hook your pullup resistors to 3.3v

Without running a calculation, I think a pull up of about 5k may be a good starting point. [ actually, since we are pulling up to only 3.3v, maybe a 4k would be better ]