
Using the device step-by-step, from basic to advanced
AN4450
16/26
DocID025978 Rev 1
4.3 One-shot
mode
measurement sequence
1.
Power down the device (clean start)
–
WriteByte(CTRL_REG1_ADDR = 0x00); // @0x20=0x00
2. Turn on the pressure sensor analog front end in single shot mode
–
WriteByte(CTRL_REG1_ADDR = 0x84); // @0x20=0x84
3. Run one-shot measurement (temperature and pressure), the set bit will be reset by the
sensor itself after execution (self-clearing bit)
–
WriteByte(CTRL_REG2_ADDR = 0x01); // @0x21=0x01
4. Wait until the measurement is completed
–
ReadByte(CTRL_REG2_ADDR = 0x00); // @0x21=0x00
5. Read the temperature measurement (2 bytes to read)
–
Read((u8*)pu8, TEMP_OUT_ADDR, 2); // @0x2B(OUT_L)~0x2C(OUT_H)
–
Temp_Reg_s16 = ((u16) pu8[1]<<8) | pu8[0]; // make a SIGNED 16 bit variable
–
Temperature_DegC = 42.5 + Temp_Reg_s16 / 480; // offset and scale
6. Read the pressure measurement
–
Read((u8*)pu8, PRESS_OUT_ADDR, 3); //
@0x28(OUT_XL)~0x29(OUT_L)~0x2A(OUT_H)
–
Pressure_Reg_s32 = ((u32)pu8[2]<<16)|((u32)pu8[1]<<8)|pu8[0]; // make a
SIGNED 32 bit
–
Pressure_mb = Pressure_Reg_s32 / 4096; // scale
7. Check the temperature and pressure values make sense
–
Reading fixed 760 hPa, means the sensing element is damaged.
Example of register measurements and conversion:
P = 0x3FF58D means 4191629 / 4096 = 1023.347 hPa
T = 0xE07C means 42.5 + (-8068/480) = 25.7 °C
{ as reference: 0x6BD0 = 100°C; 0xB050=0 °C }
The value read from the PRESS_OUT registers is always the difference of the sensor
measured pressure (after averaging) and a base value, that can be either the value copied
in the RPDS register (reference pressure after soldering, to correct the pressure offset due
to mechanical stress, 16-bit value corresponding to the MSB part of the pressure value) by
default after power-up, or the value written in the REF_P registers (24-bit value).
To select REF_P as base value, and hence enable differential mode, bit AUTOZERO (bit[1]
of CTRL_REG2, (0x21), which is a self-clearing bit) must be set: the current PRESS_OUT
value is copied into REF_P registers, and from the next available measurement, the
PRESS_OUT value is the difference between the current measure and the “frozen”
reference value. In case the application requires to switch back to default mode, the bit
RESET_AZ (bit[1] of CTRL_REG1 (0x20), which is a self-clearing bit) must be set.
PRESS_OUT is then computed using RPDS registers value as reference.
RPDS_L and RPDS_H calibration values can be written on the volatile memory by the
microcontroller after sensor power-on: the value shall be permanently stored in the
application memory during manufacturing (see
).
In special cases, there’s also the possibility to store the RPDS calibration value inside the
LPS25H non-volatile memory.