I2C interface HCLA pressure sensors (Value doesn't change)

Hello people!!

I am in a bit need of a support yet again!!

Well I am just writing an I2C interface for communicating and reading digital pressure values from HCLA02X5EB (amplified pressure sensors range) sensor from SensorTechnics (First-Sensors) using ARDUINO UNO board.

Please find below the used sketch for the communication I have been able to develop using the help from the forums:

#include <Wire.h>

float pressure_diff = 0;
int P_counts_diff;        // 16bit value
float sensitivity_p_diff = 0;
byte byte_MSB;
byte byte_LSB;
#define P_min_diff -25       // min. for the differential pressure sensor
#define P_max_diff 25     // max. for the differential pressure sensor
#define press_sensor 0x78
#define Out_min 1638     // min. counts for the sensors (same for both sensors)
#define Out_max 27852 // max. counts for the sensors (same for both sensors)


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

float read_press (){
    // initiate measurement
  Wire.beginTransmission(press_sensor);
  Wire.write(0);
  Wire.available();
  int Ack = Wire.read(); // receive a byte
  Wire.endTransmission(); 
  delay(1000); //This particular delay is the delay between the displayed values (in msec)...

  // READ DATA from here on
  Wire.beginTransmission(press_sensor);
  Wire.requestFrom(press_sensor,2);  //Reade 1 byte
  Wire.available();
  byte_MSB = Wire.read(); // receive most significant byte
  byte_LSB = Wire.read(); // receive least significant byte
  P_counts_diff = ((int)byte_MSB << 8) | byte_LSB; // Putting both bytes together
  sensitivity_p_diff = (Out_max - Out_min)/(P_max_diff - P_min_diff); // calculate the differential pressure sensors sensitivity
  pressure_diff = (P_counts_diff - Out_min)/sensitivity_p_diff + P_min_diff;   // calculate the differential pressure in [mbar]
  return pressure_diff;
  Wire.endTransmission();
}

void loop(){
  float Differential_pressure = read_press();
  Serial.print("pressure in mBar : ");
  Serial.println(Differential_pressure);
}

Now the problem is… That the sensor is constantly showing a fixed pressure value on the Serial monitor… Even if I blow air into the port the value does not change… I have also tried changing the sensors with brand new… but the problem persist…

As given in the I2C application note (http://www.first-sensor.com/cms/upload/appnotes/AN_I2C-Bus_HMI_HDI_HCLA_HCA_SSI_E_11155.pdf), I have also checked the analog output of the sensor… But surprisingly it shows also a fixed value of 2.23-2.25 V

This voltage, according to the datasheet (http://www.first-sensor.com/cms/upload/datasheets/DS_Standard-HCLA_E_11629.pdf), is the default zero-offset

What is it going wrong here… I am totally confused about the reason for this problem!

Please help!!

Deeply appreciate your support! :slight_smile: :slight_smile:

Regards

Pramit

The way you use the Wire functions is not okay.

I suppose you first write a byte value 0, and then read data. Why is there one second delay between that ? Is that in the datasheet, that a 0 must be written to start the sensor ?

Could you carefully check this function against yours ? I have removed everything that makes no sense.

float read_press (){
    // initiate measurement
  Wire.beginTransmission(press_sensor);
  Wire.write(0);
  Wire.endTransmission();

  delay(1000); //This particular delay is the delay between the displayed values (in msec)...

  // READ DATA from here on
  Wire.requestFrom(press_sensor,2);  //Read 2 bytes

  // TO DO: add a check if two bytes are received

  byte_MSB = Wire.read(); // receive most significant byte
  byte_LSB = Wire.read(); // receive least significant byte

  P_counts_diff = ((int)byte_MSB << 8) | byte_LSB; // Putting both bytes together
  sensitivity_p_diff = (Out_max - Out_min)/(P_max_diff - P_min_diff); // calculate the differential pressure sensors sensitivity
  pressure_diff = (P_counts_diff - Out_min)/sensitivity_p_diff + P_min_diff;   // calculate the differential pressure in [mbar]
  return pressure_diff;
}

Are you sure that press_sensor is the right address for your sensor ?
Did you run the i2c_scanner to check the address ?
http://playground.arduino.cc/Main/I2cScanner

Hi!

Thank you for replying!

Yes I have run the I2C scanner…

But there is a peculiar thing I have noticed that it shows two addresses for the same sensor… 0x78 (which is default) and another which is programmed…

This other address is somehow fishy… because if I open a new sensor, it should work on the default address only…

Any comments? If you have used this sensor…

Pramit

I have not used the sensor. I saw your code and noticed that the use of the Wire functions was not okay.

Why do you write a value of 0 ? I can't read in the datasheet that something has to be written.

Can you update your sketch and show it ? If you can find that something should be written, then remove those lines as well.