By using an Arduino Uno board (programming in Simulink), I am tring to read data from a BMP180 sensor and to calculate the true temperature and pressure, by following the functions shown in figure 4 (pag. 15) in the datasheet:
While the temperature reading appears correct, there are some problems with the pressure: in my opinion, by considering the “calculate true pressure” in the datasheet, the coefficients B6, X1, X2, X3, B3, B4, B7, p, UP, are returned when the value 0x2E is write into 0xF4 register: in fact, similar values are returned to me, from my BMP180, when I write the 0x2E value into 0xF4 register, instead of 0x34 (pressure, with OSS = 0).
Moreover, a pressure value of 69964 Pa appears irrealistic: by considering the figure 5, it means an altitude of about 3000 m over the sea level (I do not know if the Bosch research center is so high).
The if condition is not respected: in fact, 0x80000000 means 2147483648 in decimal. Therefore, being B7 = 1171050000 the value 70003 would be returned, as p, instead 69964.
I developed, in Simulink, two different functions: one to calculate the true temperature, the other to calculate the true pressure. If I use, as inputs, the same datasheet values, the two functions return, respectively, 150 and 70003. Therefore, they are correct.
But, if I use the real time data from the sensor, while the temperature (0x2E into 0xF4 register) is a realistic value (about 22 – 24 °C), the pressure (0x34 into 0xF4 register) is not a realistic value (about 81000 Pa), by considering an altitude of 44 m over the sea level of my office.
The BMP180 sensor run properly, since I tested it with an example for the IDE of Arduino Uno.
Therefore my question is: is the “calculate true pressure” function shown in the figure 4 of the datasheet correct or is there a problem?
Solved! Go to Solution.
I may not have completely understood your request. The source code of the function bmp180_get_pressure() shows an example of how to calculated the true barometric pressure, in C code. If your project uses Simulink as programming languange, then you could translate the C code provided as reference into Simulink code.
I don't have a BMP180 to hand, but I've used the device in an embedded system. I was programming in C and used this open source project as a reference. I can't help you fix your method, but I can suggest another.
Which uses the floating point calcs found in this doc.
Good luck and have fun.
Hi Carlo, let me explain.
In our pressure sensors, each device is calibrated at the factory and the trimming coefficients are stored in the register map. They are read in the bmp180_get_calib_param function, called automatically within bmp180_init.
For each data point, you must trigger both temperature and pressure measurements, then call the API in this order:
Point #3 is especially important, since the temperature is stored in an internal value that is used in the pressure calculation. This is also why you must read both temperature and pressure at the same time. (temperature can be sampled on its own, but pressure measurements require temperature compensation).
The mathematical formulas are on page 15 of the datasheet, but the actual meaning of it is proprietary.