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.
I am attaching the used sketch for the communication I have been able to develop using the help from the forums.
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...
Please post your code within code tags (</> above the smileys). Many people on the forum will not download attached code. The reason can be that they have a phone or tablet that can't run the IDE to view your code. For me, I just don't want another folder in my sketchbook which will be created if I download the code to view in my IDE.
Have you ran an I2C scanner to verify the address of and communication with your sensor?
Thanks so much for the insight... Here is the code
#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);
}
Yes I have run the I2C scanner... And 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...