Observe SCL and SDA pin

Hello,

I am trying to observe both the SCL and SDA pins on an Arduino Pro Mini on an oscilloscope. When I have a sensor connected (AK09970N) the serial clock seems to have about a 66% duty cycle where I expect a 50% duty cycle. When I disconnect the sensor, however, I get no cycles. Does this mean that the clock for SCL is generated by the sensor? If not, can I observe the clock generated by the Arduino?

I have used the blink example to ensure that the clock is running as expected.

1. In I2C Bus Protocol, we have the definitions for Master and Slave.

2. Master is the dvice which generates the SCL pulses.

3. There are two types of Slaves -- the Active Slave and the Passive Slave.

4. The device with its own processor and the full I2C Logic (like another UNO) is an active slave. BME280, 24C512, and the like are the examples of passive slaves; these devices don't have processors; but, they have enough I2C logic to be working as I2C devices. For example, the active slave responds to Wire.requestFrom() command and calls upon the void sendEvent() ISR. The passive slave also responds to the same command; but, it deos not call upon the void sendEvent() ISR.

5. It is possible for an active slave to become a Master and initiate bus transactions therough the generation of SCL pulses.

When I disconnect the sensor, however, I get no cycles.

The standard Arduino Pro Mini does not have pullup resistors on SCL and SDA, so you won't see any signal unless those resistors are present somewhere, for example on the sensor board.

The pullups are required for I2C communications to work. To observe the signal in the absence of a sensor, connect SDA and SCL to Vcc with 4.7K resistors.

The SCL duty cycle does not have to be 50%.

Thank you so much for explaining that about the SCL and SDA pins.

I have also now connected the sensor (with 3.3K pullup resistors as per the circuit diagram for the specific sensor).

I know how start and stop conditions are generated; however, I cannot explain the behavior of the SDA lines. Explaining the picture, yellow is SCL and green is SDA.

The relevant code is:

do
   {
      Wire.beginTransmission(AKAddress);
      bus_Status = Wire.endTransmission();
      Serial.println(bus_Status);
      delay(50);
    }
    while(bus_Status != 0);

This prints out a 2, and I am certain the address is correct.

SCL_SDA_oscilloscope.jpg

You are aware of course that SDA is two way. Either the Arduino or the device can pull it low.

Scope photo from above:
SCL_SDA_oscilloscope.jpg

That scope picture is awful, so something is wrong. If the signals actually look like that, don't expect I2C to work. Should look more like this:

From https://e2e.ti.com/support/dsp/davinci_digital_media_processors/f/537/t/200867?Communication-error-between-DM3730-and-TPS65951 (communications errors are present in the signals).

What kind of stuff should I check for in trying to debug why I might be getting such an error? I assume it is a hardware error as the code seems very straightforward.

You are probably either misusing the scope, have incorrect connections, or have pullup resistors that are way too large.

Disconnect the sensor, connect 4.7K resistors from SDA and SCL to Vcc and reexamine the signals with your scope.

If the signal traces aren't rectangular, the problem may be in the scope or the scope connections. Best if the Arduino is battery powered, or powered by a laptop that is running on its own battery, to avoid AC line ground loops with the scope.

aapatil: The relevant code is:

do
   {
      Wire.beginTransmission(AKAddress);
      bus_Status = Wire.endTransmission();
      Serial.println(bus_Status);
      delay(50);
    }
    while(bus_Status != 0);

Your codes could be written in more appropriate way as shown below:

do
{
   Wire.beginTransmission(AKAddress);
   bus_Status = Wire.endTransmission();
}
while(bus_Status != 0);
Serial.println("Slave is Present...!");