Talk to the IMU: I2C and your first sensor data
Connect the IMU over I2C and read its WHO_AM_I register. The examples use the ISM330DHCX; the comments show the values for other popular IMUs.
What an IMU measures
TheoryfreeTheory lesson: the video explains the idea. No code in this lesson.
2.2How motion becomes numbers in registers
TheoryfreeTheory lesson: the video explains the idea. No code in this lesson.
2.3STM32: connect the IMU over I2C and read WHO_AM_I
STM32freeWe continue the project from chapter 1 (printf over USART2 already works), enable I2C1 and read the identity register of the IMU.
2.3bESP32: connect the IMU over I2C and read WHO_AM_I
ESP32freeThe same as 2.3, now on the Arduino Nano ESP32 with the Wire library. No CubeMX: Wire.begin() sets up I2C on the default pins.
2.4One driver for every board: how the library works
TheoryfreeTheory lesson: the video explains why the library is built this way; this page shows each part.
2.5STM32: build a reusable IMU driver
STM32freeWe move the IMU code out of main.c into a driver for our chip. The driver only uses three board functions (read, write, delay), given through function pointers. main.c provides them with HAL (lesson 2.6). Using another IMU? Take its two files from the steps below instead of ism330dhcx.h / .c: the rest is the same.
2.6STM32: read accelerometer and gyroscope data
STM32freeCopy each step into main.c, at the place shown above the code. Keep everything between the USER CODE comments.
2.6bESP32: read accelerometer and gyroscope data
ESP32freeThe driver files from 2.5 work on the ESP32 without a single change. We only write the three board functions with Wire, then start the sensor and read it at 50 Hz with the loop from 1.5.