I2C write on Uno not working

I’m trying to communicate with a camera over I2C. Right now, I just want it to send back the two bytes of it’s device ID. When I look at the output of the SDA, it looks like it sends the address of the device twice and then stops sending anything at all. I’ve tried writing to different registers just to see what would happen and I get the same result. When I look at the error code coming back from Wire.endTransmission(), I get a 2. What’s happening here?

sketch_apr04a.ino (500 Bytes)

Wire.beginTransmission(0xBA);

That address is greater than 127 which is the highest address possible with the 7 bit addressing of the Wire library. Run this I2C scanner to see if the camera is on the I2C bus and its address. Use the address in your code that the scanner reports (if any).

// I2C scanner by Nick Gammon.  Thanks Nick.

#include <Wire.h>

void setup() {
  Serial.begin (115200); //*****  make sure serial monitor baud matches *****

  // Leonardo: wait for serial port to connect
  while (!Serial) 
    {
    }

  Serial.println ();
  Serial.println ("I2C scanner. Scanning ...");
  byte count = 0;
  
  Wire.begin();
  for (byte i = 1; i < 120; i++)
  {
    Wire.beginTransmission (i);
    if (Wire.endTransmission () == 0)
      {
      Serial.print ("Found address: ");
      Serial.print (i, DEC);
      Serial.print (" (0x");
      Serial.print (i, HEX);
      Serial.println (")");
      count++;
      delay (1);  // maybe unneeded?
      } // end of good response
  } // end of for loop
  Serial.println ("Done.");
  Serial.print ("Found ");
  Serial.print (count, DEC);
  Serial.println (" device(s).");
}  // end of setup

void loop() {}

You should post your code in accordance with the guidelines in the how to use this forum sticky. More members will be able to see your code that way,

lchomas:
When I look at the error code coming back from Wire.endTransmission(), I get a 2. What's happening here?

When I2C bus communications are successful, the 'byte err_msg = Wire.endTransmission();' returns 0x00 via variable err_msg. In your case, the slave device has not been detected by the Master.

Please give a link of your camera so that we can check its address.

Thanks for that! That solved it. The address the scanner found doesn't match the datasheet, but it works!
Sorry for the poor form on the code!

lchomas:
When I look at the output of the SDA

I'm keen to know what means you have at your disposal to do that.

When you change the code, please post the latest version (in code tags) so that we can keep up.

I’m keen to know what means you have at your disposal to do that.

I don’t know what the OP has, but I use a logic analyzer like this one with the Pulseview software. The Pulseview software has several decoders and I2C is one of them.

groundFungus:
I use a logic analyzer like this one

Nice.