# Attempting to program the AD7745 to detect capacitance values

**URL:** <https://forum.arduino.cc/t/attempting-to-program-the-ad7745-to-detect-capacitance-values/1105791>\
**Category:** Interfacing w/ Software on the Computer\
**Created:** [March 23, 2023, 5:12pm UTC](https://forum.arduino.cc/t/attempting-to-program-the-ad7745-to-detect-capacitance-values/1105791 "2023-03-23T17:12:15Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![cathalmurphy](https://avatars.discourse-cdn.com/v4/letter/c/278dde/32.png) [@cathalmurphy](https://forum.arduino.cc/u/cathalmurphy)\
**Post date:** [March 23, 2023, 5:12pm UTC](https://forum.arduino.cc/t/attempting-to-program-the-ad7745-to-detect-capacitance-values/1105791/1 "2023-03-23T17:12:15Z")

</div>

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:

```cpp
#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.

---

<div class="post-metadata">

**Author:** ![Railroader](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/railroader/32/274550_2.png) [@Railroader](https://forum.arduino.cc/u/Railroader)\
**Post date:** [March 23, 2023, 5:41pm UTC](https://forum.arduino.cc/t/attempting-to-program-the-ad7745-to-detect-capacitance-values/1105791/2 "2023-03-23T17:41:09Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![system](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/system/32/1140315_2.png) [@system](https://forum.arduino.cc/u/system)\
**Post date:** [September 19, 2023, 5:42pm UTC](https://forum.arduino.cc/t/attempting-to-program-the-ad7745-to-detect-capacitance-values/1105791/3 "2023-09-19T17:42:08Z")

</div>

Closed on September 19, 2023, 5:42pm UTC

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