i'm working on a own Arduino Flightcontroller and am trying to get a BMP388 working. I want to estimate the altitude.
I got the task done with the Adafruit Library, but it takes 2.5 microseconds to read the Sensor and get the altitude. Thats way to slow for a quadrocopter.
That's why i try to write my own Code and for a performance. I think i'm able to read the 24bit pressure data from the register 0x04:
Wire.beginTransmission(BMP_ADDR); //Start communication with the BMP.
Wire.write(0x04); //Start reading @ register 0x04 and auto increment with every read.
Wire.endTransmission(); //End the transmission.
Wire.requestFrom(BMP_ADDR,6); //Request 6 bytes from the gyro.
while(Wire.available() < 6); //Wait until 6 Byte are recieved
pressure = (Wire.read()<<16) | (Wire.read()<< 8 ) | (Wire.read());
druck = (float)pressure/0.33;
temperature = (Wire.read()<<16) | (Wire.read()<< 8 ) | (Wire.read())
But i'm not sure if i understand how to get the pressure in Pa the right way.
What i do:
druck = (float)pressure/0.33;
I set the Oversamplingrate of the Pressure to x8. In the Datasheet is wirtten on page 13:
x8 Oversampling 19bit/0.33 Pa resolution.
The datasheet and the Adafruit library do many calculations to get the temperature and the pressure.
I see now that a faster sampling is possible when the temperature is not needed. The 0.33 is the resolution. As far as I can tell the number from the registers is not the pressure in Pa, I think you still have to do all those calculations. But I'm not sure, I always use a library with all those calculations for a Bosch sensor, without thinking about it.
400kHz is about 25µs per byte.
The GetBMPData transfers 6 bytes (or 9 with the bug). That is 150µs (or 225µs with the bug). Plus 50% overhead. Plus the rest of the function.