
Software
AN4450
22/26
DocID025978 Rev 1
6 Software
A detailed register list is reported in the LPS25H datasheet. In This section we collect useful
information on how to handle possible exceptions on the communication bus and how to
properly use the information coming from the device.
6.1 Hints
1.
If the I
2
C line has glitches and slaves are holding SDA low, a simple I
2
C error recovery
would be to send 9 stop bits (which will flush the bus). This is usually done by SW using
the I
2
C GPIOs resources of the host device. A good practice would be to check that
SDA is high prior to generating a START bit.
2. The serial bus power consumption can be reduced by reducing the data traffic:
–
Using built-in HW averaging instead of SW averaging
–
Reduce the polling rate when waiting for the one-shot measurement completion
(
–
The INT1 pin can be used as event to minimize serial bus polling
6.2
One-shot mode conversion time estimation
Typical conversion time
62*(Pavg+Tavg) + 975 µs
ex: Tavg = 64; Pavg = 512; Typ. conversation time
36.7 ms (compatible with
ODT=25 Hz)
ex: Tavg = 32; Pavg = 128; Typ. conversation time
10.9 ms
The formula is accurate /- 3% at room temperature
6.3
Reference SW to get started with LPS25H
There are some examples of C source files that provide the baseline in initializing,
configuring and performing measurements with the pressure sensor.
6.4
Pressure to altitude conversion
The simplest and widely used barometer (altitude) formula used in most watches comes
from the US Standard Atmosphere, for example the 1976 edition.
Example of the source code is shown below:
void From_Pressure_mb_To_Altitude_US_Std_Atmosphere_1976_ft(double*
Pressure_mb, double* Altitude_ft) {
//=(1-(Pressure/1013.25)^0.190284)*145366.45
*Altitude_ft = (1-pow(*Pressure_mb/1013.25,0.190284))*145366.45;
}
void From_ft_To_m(double* ft, double* m) {