Wire library help needed just i2c address transmitted

Trying to study the Wire library, I read some info taken from here.
As you all know, this really simple example changes the value of a AD5171 digital potentiometer via I2C. Written by Nicholas Zambetti and Shawn Bonkowski, demonstrates use of the Wire library.

I just copied and adapted the code below from the example. I am an experienced assembler and C/C++ programmer and hardware developer/designer.
Although several I2C devices like DS3231 RTC, etc. work fine using standard Arduino libraries, the mentioned example doesn't work for me in my working NANO board.
What am I doing wrong, please?

This code should transmit:
1 - first the I2C protocol device address - Start / 8 + 1bits
2 - 1 test instruction data byte
3 - 1 variable test byte constantly incremented
4 - I2C Stop condition

The only byte I can see in my oscilloscope is just the first one (picture attached). The 2 data bytes are not being transmited. If I reduce the transmission to just the step (2) instruction single data byte, same result is shown.

#include <Wire.h>

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

byte val = 0;

  void loop() 
{
  Wire.beginTransmission(44); // transmit to device #44 (0x2c)
  Wire.write(byte(0x55));     // sends instruction byte
  Wire.write(val++);          // sends potentiometer value byte
  Wire.endTransmission();     // stop transmitting
  delay(50);                  // some time delay for my oscilloscope
}

Thank you in advance
Robert

shouldn't that be 0x00 ? (from https://www.arduino.cc/en/Tutorial/LibraryExamples/DigitalPotentiometer)

Check the code returned by Wire.endTransmission().

Even if your scope screenshot looks differently the transmission abort may indicate that no slave responded to that I2C address. Run the I2c_scanner example to find out the real I2C address of your sensor.

Ahhhhhhhhh !
Thank you DrDiettrich, that must be the reason.
I will test this and return to report.
The documentation that I have available doesn't mention that the function aborts if no slave responds on the bus. The function must be checking the ACK/NACK mechanism, which is correct. My intention was to make an "open loop" test.

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.