# Project help !

I am trying to read the readings from the pressure sensor.I have three bytes wihch compromise the reading.Whole number part of the reading compromises of the 18 bits in total(MSB + CSB + 6th and 7th bit of LSB), where as fractinal partof the reading comprises of the 4h and 5th bit of the LSB.
I have made this solution to fetch the final reading using these bytes.
float Calculate_pressure(){
unsigned long m_pressure = I2Cdata[0];
unsigned long c_pressure = I2Cdata[1];
unsigned long l_pressure = (I2Cdata[2]>>4)/4;
m_pressure=m_presssure<<!2;
c_pressure=c_pressure<<4;
m_pressure|=c_pressure;

return((float)(m_pressure|l_pressure));
}
Here I2Cdata[0],I2Cdata[1] and I2Cdata[2] are MSB,CSB and LSB respectively.

Is this algorithm is correct ? ?

Hello and welcome,

http://www.nxp.com/files/sensors/doc/data_sheet/MPL3115A2.pdf

I donâ€™t thing that is an algorithm. Maybe a procedure.
`m_pressure=m_presssure<<!2;` Typo?
You really need some white space between the "l"s and the "|"s.

``````unsigned long l_pressure = (I2Cdata[2]>>4)/4;
``````

is the same as:

``````unsigned long l_pressure = I2Cdata[2]>>6;
``````

or:

``````unsigned long l_pressure = I2Cdata[2]/64;
``````