How to use the LIS2DUXS12 part API.
It illustrates it by getting the values of the accelerometer (in mg) and displaying them on a terminal.
Initialization phase: At main program start, the mx_system_init() function is called. It initializes the peripherals, nonvolatile memory (such as flash memory, NVM, or external memories), MPU regions (if applicable), the system clock, and the SysTick.
The application executes the following example steps:
Step 1: Initializes and enables accelerometer feature of LIS2DUXS12
Step 2: Gets the values of the accelerometer (in mg) and displays 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: LIS2DUXS12 sensor init completed
[INFO] Step 1: Enabling the ACC feature completed
[INFO] Step 2: ACC X=88 Y=-72 Z=1007
This example demonstrates the following driver:
- Part lis2duxs12.c/.h
- Part lis2duxs12/interfaces/i2c/lis2duxs12_io.c/.h
In this example, the LIS2DUXS12 component is configured through the I2C IO operations defined under the folder interfaces/i2c. Once the I2C is initialized, the LIS2DUXS12 can be initialized too through the call of lis2duxs12_drv_init() API. After this step, the MEMS sensor will be ready to provide the values of the accelerometer.
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 = 0x33 (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_lis2duxs12_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 LIS2DUXS12 part driver can be found in the LIS2DUXS12 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.