How to use part LPS22DF API.
It illustrates it by getting the value of the temperature (in celsius) and of pressure (in hPascal) and displaying them on a terminal.
Initialization phase: At the beginning of the main() function, the mx_system_init() function is called to initialize the peripherals.
The application executes the following example steps:
Step 1: Initializes and enables temperature feature of LPS22DF
Step 2: Gets the values of the temperature (in celsius) and of pressure (in hPascal) and display them on a terminal
End of example: It is an endless example that loops infinitely on step 2.
You can follow these execution steps in the terminal logs:
[INFO] Step 1: LPS22DF sensor init completed
[INFO] Step 1: Enabling TEMP and PRESS feature completed
[INFO] Step 2: TEMP 31 degC
[INFO] Step 2: PRESS 1081 hPa
This example demonstrates the following driver:
- Part lps22df.c/.h
- Part lps22df/interfaces/i2c/lps22df_io.c/.h
In this example, the LPS22DF component is configured through the I2C IO operations defined under the folder interfaces/i2c. Once the I2C is initialized, the LPS22DF can be initialized too through the call of lps22df_drv_init() API. After this step, the MEMS sensor will be ready to provide the values of the temperature and pressure.
This section describes the hardware setup principles that apply to any board.
On STM32C5 series.
On board NUCLEO-C562RE.
| Board connector | MCU pin | Signal name | ARDUINO connector pin |
|---|---|---|---|
| CN5-10 | PB6 | I2C1_SCL | ARDUINO CONNECTOR - D15 |
| CN5-9 | PB7 | I2C1_SDA | ARDUINO CONNECTOR - D14 |
- I2C ADDw = 0x5D (7-bit address).
To create a functional project, complete the following steps:
- Select the appropriate IoC2 file based on the combination of NUCLEO and X-NUCLEO boards. For example, use c562re_iks4a1_lps22df_datalog_i2c.ioc2 for NUCLEO-C562RE and X-NUCLEO-IKS4A1.
- Open the IoC2 file with STM32CubeMX2.
- Select the preferred toolchain and generate the source code.
- Copy the main.c, main.h, example.c, and example.h files into the project folder of the generated code.
- Open the Integrated Development Environment (IDE), add the example.c and example.h files to the project.
- Add the USE_TRACE=1 to the global variables of the project.
- Compile the project.
No specific debug tips.
More information about LPS22DF part driver can be found in the LPS22DF Part Driver
More information about the STM32 ecosystem can be found in the STM32 MCU Developer Zone.
Copyright (c) 2026 STMicroelectronics.
This software is licensed under terms that can be found in the LICENSE file in the root directory of this software component. If no LICENSE file comes with this software, it is provided AS-IS.