How to use MPU6050 to generate interrupts and wake up STM32 in sleep mode?

Using the MPU6050 to generate an interrupt and wake up an STM32 microcontroller from sleep mode is a common technique in low-power motion detection applications. Here's a complete step-by-step guide: Goal: Configure MPU6050 to generate an interrupt on motion. Connect the INT pin of MPU6050 to an EXTI (external interrupt) pin on the STM32. Wake up the STM32 from sleep (or stop/standby) mode on motion detection. Step 1: Hardware Connections MPU6050 STM32 (e.g., STM32F103 ) VCC 3.3V GND GND SDA I2C SDA (e.g., PB7) SCL I2C SCL (e.g., PB6) INT GPIO with EXTI (e.g., PA0) Use pull-up resistors (4.7kΩ) on SDA/SCL lines if not present. Step 2: MPU6050 Configuration (Motion Interrupt) Use I2C to configure MPU6050: c // Wake up MPU6050 i2c_write(MPU6050_ADDR, PWR_MGMT_1, 0x00 ); // Clear sleep bit // Set accelerometer threshold i2c_write(MPU6050_ADDR, MOT_THR, 10 ); // Threshold (sensitivity) // Set motion duration i2c_write(MPU6050_...