Attempting to program the AD7745 to detect capacitance values

For my project, I am using an AD7745 to detect the capacitance in a droplet as it passes. I have the wiring correctly connected, though I think there may be issues with the code:

#include <Wire.h>  

// Define the AD7745 I2C address and register addresses
// These address pointers were from page 14 of the AD7745 datasheet
#define AD7745_ADDRESS 0x48 
#define AD7745_CAPDATA 0x00 
#define AD7745_CONFIGURATION 0x01
#define AD7745_CAPACITANCE_MSB 0x02 
#define AD7745_CAPACITANCE_LSB 0x03

const int AD7745_RDY_PIN = 28;// RDY pin is connected to digital pin 28 on Arduino Due

// Define a variable to hold the capacitance value
float capacitanceValue;

void setup() {
  Serial.begin(9600);
  Wire.begin();
  // Set the AD7745 configuration
  Wire.beginTransmission(AD7745_ADDRESS);
  Wire.write(AD7745_CONFIGURATION);
  Wire.write(0x00); 
  Wire.endTransmission();
  
  // Set the Arduino digital pin for the AD7745 RDY pin as an input
  pinMode(AD7745_RDY_PIN, INPUT);
}

void loop() {
  // Wait for the AD7745 RDY pin to go high
  while (digitalRead(AD7745_RDY_PIN) == LOW) {}

  // Read the capacitance value from the AD7745
  Wire.beginTransmission(AD7745_ADDRESS);
  Wire.write(AD7745_CAPACITANCE_MSB);
  Wire.endTransmission();
  Wire.requestFrom(AD7745_ADDRESS, 2);
  uint8_t msb = Wire.read();//variables to store two bytes of data read from AD7745
  uint8_t lsb = Wire.read();
  capacitanceValue = ((msb << 8) | lsb) * 0.000001;  // Convert raw value to capacitance in farads
  
  // Print the capacitance value to the Serial monitor
  Serial.print("Capacitance value: ");
  Serial.print(capacitanceValue, 6);  // Print with 6 decimal places
  Serial.println(" F");
  
  // Wait for a short time before starting the next conversion
  delay(100);
}

What I am trying to do is that I want to see that the capacitance can change if I wave my hand above it, even when there are no capacitors connecting to its appropriate pins. The problem I am encountering is that the serial monitor is continuously producing the exact same capacitance value every second with absolutely no changes whether I have the capacitor connected to it or not.

Check up this topic: "How to get the best out of this forum." regarding posting code.
Forum is usually interested in schematics for issues like this. Pen and paper often works well.

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