Arduino Interfacing over I2C with AD7746

Hi All,

I am trying to interface an arduino UNO with an AD7746 over I2C. Currently i have a simple script to write to the configuration register and then read back the configuration:

#include <Wire.h>

#define I2C_ADDRESS  0x48 

void setup() {
  Wire.begin();
  Serial.begin(9600);
}

uint8_t readI2C(byte reg) {
  Wire.beginTransmission(I2C_ADDRESS);
  Wire.write(reg); 
  Wire.endTransmission();

  Wire.requestFrom(I2C_ADDRESS, 1); 

  uint8_t value = 0;
  if(Wire.available()) {
    value = Wire.read();
  }
  
  return value; 
}

bool writeI2C(byte reg, byte data) {
  Wire.beginTransmission(I2C_ADDRESS);
  Wire.write(reg);
  Wire.write(data);
  int error = Wire.endTransmission();
  
  if(error == 0)
    return true; // success
  else
    return false; // failure
}

void loop() {
  bool writeResult = writeI2C(0x09, 0x10);
  Serial.print("Write to 0x09: ");
  Serial.println(writeResult ? "Success" : "Failure");
  delay(300);
  uint8_t data = readI2C(0x09);
  Serial.print("Read 0x09: ");
  Serial.println(data, HEX);

  delay(100); 
  
}

The problem I have is that the code is able to read from the register perfectly fine but the value I read after the write function does not match the value that should have been written. It is almost like the register is read only.

According to the datasheet (link below) it is a Read and Write register so i guess there shouldnt be an issue with what i am trying to do. Has anyone come across anything similar to this or have any suggestions on why i might not be able to write to the AD7746. I have also tried other writeable registers with the same code and get the same issue.

Any help or advice would be greatly appreciated!

Welcome to the forum.

Can you try another capacitance sensor ?

Here is something about the chip on Hackaday: https://hackaday.com/2009/07/18/capacitance-sensor-guide-ad7746/.
The link to the original website does no longer work, but it can be found in the Internet Archive: https://web.archive.org/web/20100104095245/http://interactive-matter.org/2009/07/arduino-ad7746/
After reading that, it is not a straight-forward or easy-to-use chip.

Thank you for the whole sketch between code tags :smiley:
On this forum we like to know what you expect and what you get. You write 0x10, but which value do you read ?

Hi Koepel,

Thanks for the response, ive tried another AD7746 chip i have and am getting simialr results.

I am setting the register to 0x10 but im getting a value of 0x02 back from the register when i poll it.

I have used that article previously with very similar results not being able to set the write values, which is why i decided to strip the code down to the bare minimum to see if there was anything in the code causing the issue.

Its definetly not the most fun chip ive interfaced with!

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