I have a Honeywell ASDXRRX100PD2A5 I2C Pressure Sensor that I want to read using an Arduino.
Looking at the datasheet, I know that the I2C address is 0x28, and I have had a play with bits of code I've found on the internet, but none of them make any sense. Numbers do increase as I increase the pressure, but not on the scale shown on the datasheet.
Here is a link to said datasheet: http://www.farnell.com/datasheets/1676926.pdf
Here is a datasheet that has information about communicating with Honeywell sensors using I2C: http://sensing.honeywell.com/index.php/ci_id/45841/la_id/1/document/1/re_id/0
Without having much experience with I2C in the past it's hard for my to get my head around it.
Also, here is a picture of my setup:
The code I am using to test it out at the moment is as follows:
#include<Wire.h>
#define sensor 0x28 //Unique bus address
void setup()
{
Wire.begin();//Wakes up I2C bus
Serial.begin(9600);
}
void getdata(byte *a, byte *b)
{
//Move register pointer back to first register
//Wire.beginTransmission(sensor);
//Wire.write(1);
//Wire.endTransmission();
Wire.requestFrom(sensor,2);//Sends content of first two registers
*a = Wire.read(); //first byte recieved stored here
*b = Wire.read(); //second byte recieved stored here
}
void showdata()
{
byte aa,bb;
float pressure =0;
getdata(&aa,&bb);
Serial.print("byte 1: ");Serial.println(aa,DEC);
Serial.print("byte 2 ");Serial.println(bb,DEC);
delay(1000);
}
void loop()
{
showdata();
}
I am getting the following results at the following pressures:
0psi byte1: 31
byte2: 246
10psi byte1: 34
byte2: 102
20psi byte1: 32
byte2: 30
30psi byte1: 39
byte2: 167
Any help pointing me in the right direction would be much appreciated.
Best Answer
What's wrong?
Sensor is differential, up to 100psi.
so \$P_{min}\$ is -100psi, \$P_{max}\$ is +100psi.
Total 14 bit (from 0 to 214-1),
\$P_{min}\$ is at 10%, so \$OUTPUT_{min}\$ is 1638
\$P_{max}\$ is at 90%, so \$OUTPUT_{max}\$ is 14745
from datasheet: $$ P=\dfrac{(OUTPUT - OUTPUT_{min}) \cdot (P_{max} - P_{min})} {OUTPUT_{max} - OUTPUT_{min}} + OUTPUT_{min}$$
according to datasheet pressure is:
$$\dfrac{(8182 - 1638) \cdot (100 - (-100))}{14745 - 1638} - 100 \approx -0.14496071$$
$$ \dfrac{(8806 - 1638) \cdot (100 - (-100))} {14745 - 1638} - 100 \approx 9.376669$$
precision is not so good, but it is still acceptable
$$\dfrac{(8222 - 1638) \cdot (100 - (-100))} {14745 - 1638} - 100 \approx 0.46540017$$
something goes wrong, it isn't like 20psi, it is like 0psi.
$$ \dfrac{(10151 - 1638) \cdot (100 - (-100))} {14745 - 1638} - 100 \approx 29.900053$$