Getting a NACK from I2C Slave when sending multiple bytes from master

I need help with I2C communication.
The master IC (Arduino Uno) is communicating with a digital potentiometer at address 0101 0000 (only 7 bit 010 1000 in beginTransmission).
First I need to send 0000 0000 as the address for the wiper register I want to write to.
(Everything up until now works perfectly fine by itself)
When I add the second write line Wire.write(byte(res_value)) to write a value to the register at 0x00 the slave sends a NACK already after Wire.beginTransmission(ADDR_POTI)
But it sends an ACK after Wire.beginTransmission(ADDR_POTI) as well as Wire.write(byte(res_value)) when I only send these two lines and Wire.endTransmission()

Please if you have any idea on how to make this work, tell me.

Edit: Thanks for your replies, swapped the image with code.
Am using the DS3501 Digital Potentiometer https://www.analog.com/media/en/technical-documentation/data-sheets/DS3501.pdf

I got the info about NACK or ACK respectively from measuring the SDA Line via analog oscilloscope. I do not have documentatin of these signals atm

#include <Wire.h>
#define ADDR_POTI B0101000
#define ADDR_RESISTANCE_REGISTER B00000000

byte res_value = 20;
byte read_res_value = 0;

void setup()
{
  Wire.begin();       // join i2c bus
  Serial.begin(9600);
}

//Potentiometer takes values ranging (0...127 dec) into Wiper Register for setting resistance(127 built-in resistors)

void loop()
{
  Wire.beginTransmission(ADDR_POTI);              // transmit to device at Address 0101 0000 (digital potentiometer)
  Wire.write(ADDR_RESISTANCE_REGISTER);           // register address, write
  Wire.write(byte(res_value));                    // Store res_value in register
  Wire.endTransmission();
  delay(1);
}

There exist more than one pot. Please give a link to the datasheet.

Follow the forum guidelines, your code is not legible.

1. Post your sketch and NOT the image of the sketch.

2. To note:
I2C Slave Address is 7-bit
I2C Bus Address is 8-it

3. The Wire.beginTransmission() accepts 7-bit Slave Address as argument and the it is transformed into 8-bit by appending 0 or 1 (Write mode or read mode) at the right-most position of Slave Address.

4. How do you know that the Slave has sent NACK unless you print the status?

byte busStatus = Wire.endTransmission();
if(busStatus != 0)
{
    Serial.print("Slave has sent NACK.");
    while(1);  //wait for ever
}

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