Pressure sensor

Hi there! This is my very first post, so please, dont roast me too much!

I’ve been playing with arduinos and sensor for a little while, just for fun tho, but found out it could be useful for my job, so i decided to give it a try and make something useful. So far, ive done easy projects which had tutorials and stuff, but this new thing does not. Done with the introduction here goes my problem!

I would like to measure small pressure inside a bottle, for this purpouse im using this sensor; ABPDLNN100MG2A3, the datasheet is attached. At the end, if i want to get the pressure, ive got to put the % of the output in a lineal regression, the equation is inside the datasheet, thing is, how do i get that % of the output, as far as i know, the resolution is 14 bit, so i guess the value the sensor gives me are 14 bits, with a crappy (really crappy) code, i get the 14 bits and turn them to decimal, im sure its wrong, as the range of the sensor is 0 to 10000 Pa, and , with a few Pa (20 or so, measured with the tool we use in the lab.) it gives me the higher value (2^14), also, im not pretty sure, but its gauge sensor, so it makes the difference between the atmospheric pressure and the pressure its measuring, and i think, if theres no pressure applied , the output should be close to 0, which is not.

Heres the code (please dont laugh), ive seen other posts, with similar stuff, but i dont really understand how i can apply that here.

#include <Wire.h>

int adress = 40;

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

void loop() {

int c = read_pres(40);
delay(1000);
int b1 = bitRead(c,0);
int b2 = bitRead(c,1);
int b3 = bitRead(c,2);
int b4 = bitRead(c,3);
int b5 = bitRead(c,4);
int b6 = bitRead(c,5);
int b7 = bitRead(c,6);
int b8 = bitRead(c,7);
int b9 = bitRead(c,8);
int b10 = bitRead(c,9);
int b11 = bitRead(c,10);
int b12 = bitRead(c,11);
int b13 = bitRead(c,12);
int b14 = bitRead(c,13);
Serial.print(b1);Serial.print(b2);Serial.print(b3);Serial.print(b4);Serial.print(b5);Serial.print(b6);Serial.print(b7);Serial.print(b8);Serial.print(b9);Serial.print(b10);Serial.print(b11);Serial.print(b12);Serial.print(b13);Serial.println(b4);
Serial.println(c);
delay(5000);

}
int read_pres(int prueba){
Wire.beginTransmission(adress);
Wire.write(0);
Wire.endTransmission();
Wire.requestFrom(adress, 1);
while(Wire.available() == 0);
int c = Wire.read();
return c;
}

Well, thanks in advance!

Couldnt attach the file, heres the link.

Before you get too roasted. Take a read through the sticky post and particular the section on posting code and using the code tags, then edit your first post.

I think you’ve missed a mark. The bottom of page three tells you what you need to know. The value is returned in counts between 0 and 16383. Take you reading divide by 16383 and multiply by 100 to get percent.

You don’t need all that bit stuff. Also the read is for one byte (8 bits). I think it needs to read 2 bytes Wire.requestFrom(address, 2). You will need to then combine the two bytes into one integer.

How did you wire the sensor? According to the part number you have a 3.3V sensor, so connecting 5V I2C signals might damage it.

According to the I2C interface manual (seems to be identical for all Honeywell pressure sensors) you don’t have to address any register but simply read the first 4 bytes:

int read_pres(byte address){
  if (Wire.requestFrom(address, 4)) {
    int rawpressure = Wire.read();
    uint8_t status = rawpressure >> 6;
    rawpressure = (rawpressure << 8) | Wire.read();
    int rawtemp = Wire.read();
    rawtemp = ((rawtemp << 8) | Wire.read()) >> 5;
    return rawpressure;
  }
  return -1;
}

You then have to calculate the effective pressure using the provided algorithm.

Thank you both, but solved it yesterday, found the "second part" of the instructions, and must say it works perfect!