Hey everyone, I am using the AD7151(Data Sheet) to get the capacitance data from a capacitance pressure sensor, But AD7151 just don't working, I can't get response from Serial Monitor.
I'm using 5V arduino nano as my master and my slave is 3V3 device, so Level Shift also include. here are my circuit and code.
#include <Wire.h>
#define AD7150_I2C_ADDRESS 0x48 //AD7150 adress
#define AD7150_REG_STATUS 0x00
#define AD7150_REG_CH1_DATA_HIGH 0x01
#define AD7150_REG_CH1_DATA_LOW 0x02
#define AD7150_REG_CH1_AVERAGE_HIGH 0x05
#define AD7150_REG_CH1_AVERAGE_LOW 0x06
#define AD7150_REG_CH1_SENSITIVITY 0x09
#define AD7150_REG_CH1_TIMEOUT 0x0A
#define AD7150_REG_CH1_SETUP 0x0B
#define AD7150_REG_CONFIGURATION 0x0F
#define AD7150_REG_POWER_DOWN_TIMER 0x10
#define AD7150_REG_CH1_CAPDAC 0x11
#define AD7150_REG_SERIAL_NUMBER_3 0x13
#define AD7150_REG_SERIAL_NUMBER_2 0x14
#define AD7150_REG_SERIAL_NUMBER_1 0x15
#define AD7150_REG_SERIAL_NUMBER_0 0x16
#define AD7150_REG_CHIP_ID 0x17
void setup() {
// put your setup code here, to run once:
Serial.begin(9600);
Wire.begin();
Wire.beginTransmission(AD7150_I2C_ADDRESS);
Wire.write(AD7150_REG_CH1_SETUP); //Move pointer to the register address
Wire.write(203); //Setup features for range bx11001011
Wire.endTransmission();
delay(4);
Wire.beginTransmission(AD7150_I2C_ADDRESS);
Wire.write(AD7150_REG_CONFIGURATION); //Move pointer to the register address
Wire.write(49); //Configuration of the threshold mode bx00110001
Wire.endTransmission();
delay(4);
}
void loop() {
//Get capacitance data
Wire.beginTransmission(AD7150_I2C_ADDRESS); // "Hey, AD7150 @ 0x48! Message for you"
Wire.write(AD7150_REG_CH1_DATA_HIGH); // "move your register pointer to get DATA_HIGH
Wire.endTransmission(); // "Thanks, goodbye..."
Wire.requestFrom(AD7150_I2C_ADDRESS,1); // "Hey AD7150 send me your data with 1 byte"
byte ch1H = Wire.read();
Wire.beginTransmission(AD7150_I2C_ADDRESS); // "Hey, AD7150 @ 0x48! Message for you"
Wire.write(AD7150_REG_CH1_DATA_LOW); // "move your register pointer to get DATA_LOW
Wire.endTransmission(); // "Thanks, goodbye..."
Wire.requestFrom(AD7150_I2C_ADDRESS,1);
byte ch1L = Wire.read();
unsigned int ch1 = ch1H*256 + ch1L; //Concatanates the two bytes into one 16 bit word
float Cap1 = (ch1-12288)*4.0/40944.0; // Converts the digital value into capacitance, formula from datasheet.
//print the data on serial monitor
Serial.print("Ch1=");
Serial.print(ch1, BIN);
Serial.print(" Ch1=");
Serial.print(ch1);
Serial.print(" C1=");
Serial.println(Cap1,2);
delay(700);
}