I'm using Arduino Wire.h header and trying to illustrate 8 bit signal on oscilloscope

I'm taking Clock data(SCL) from A5 and SDA from A4 port in Arduino UNO board. The code below is used to illustrate 8 bit signal on oscilloscope. The problem is that the 8 bit signal is not totally square wave and ACK bit is high. Please help me.

#include <Wire.h>

void setup()
{
Wire.begin(); // join i2c bus (address optional for master)
}

byte x = 0;

void loop()
{
Wire.beginTransmission(170); // transmit to device #4
Wire.write(0x07); // sends five bytes
Wire.endTransmission(); // stop transmitting
x++;        // increment value
  if (x == 127) { // if reached 64th position (max)
    x = 0;    // start over from lowest value
  }
delay(10);
}

The result is:

Adding 4.7K external pullup resistors for SCL and SDA should help (alot).

thank you for your replying. How to connect resistors?

“Pull up” -wire each of A4/5 via each of the 4k7 to the 5v supply

Is it correct? But signal is incorrect.

That signals a missing receiver (slave).

Impossible to say from that picture

Hi, @oyunerdene102521
Can you please draw a simple circuit showing your UNO, Scope and connections including resistors?
An image of a hand drawn diagram would be fine.

What Scope probes are you using?

Thanks.. Tom... :grinning: :coffee: :australia: :+1:

You are using the address 170 (0xAA, 0b10101010) which gets truncated to 0x2A (0b0101010) because the Wire library expects 7-bit addresses. The address then gets shifted left one bit to make room for the Read/Write bit. Write is 0 so the address byte being sent is: 0b01010100. That looks like what you have on the scope.

I think the 9th clock rising edge is where the bus master samples the ACK signal. Since there is no device at address 0x2A there is no ACK.