yahboom
HomeLearn
Solution
Blog
Online Store
About Us
EN/中文
IMU Sensor Module📖
1. Introduction to the IMU Module
  • Introduction to IMU Module
2. Multi-master communication case
1. PC Communication
  • For PC
2. Serial communication
  • For STM32F103C8T6
  • For MSPM0G3507
  • For MSPM0G3519new
  • For ESP32
  • For Arduino
  • For Raspberry Pi Pico
  • For Raspberry Pi 5
  • For Jetson
  • For RDK
3. IIC Communication
  • For STM32F103C8T6
  • For MSPM0G3507
  • For MSPM0G3519new
  • For ESP32
  • For Arduino
  • For Raspberry Pi Pico
  • For Raspberry Pi 5
  • For Jetson
  • For RDK
3. Application Cases of Microcontroller-Based Cars
  • 1. Autonomous Driving Car
4. ROS Application Cases
ROS1 Applications
  • 1. IMU data printing
  • 2. Rviz Visualization
  • 3. IMU-integrated radar mapping and navigation
ROS2 Applications
  • 1. IMU data printing
  • 2. Rviz Visualization
  • 3. IMU-integrated radar mapping and navigation
Download
  • Code
  • VM_File
  • Docker_Image
  • 3D_Model_File
  • Hardware_DataSheet
  • Communication_Protocol
  • PC_Software
Download ZIP

Welcome to IMU Sensor Module repository

For ESP32

ESP32-IIC Data Reading

ESP32-IIC Data Reading1. Connecting Devices2. Key Code Analysis3. Reading IMU Data

This example uses the ESP32-WiFi image transmission module Lite version (Yabo), a Windows computer, several DuPont wires, an IMU attitude sensor, and a USB to TTL module.

1. Connecting Devices

IMU Attitude SensorESP32-WiFi Image Transmission Module Lite (Yahboom)
SDASDA
SCLSCL
GNDGND
3V33V3
USB to TTLESP32-WiFi Image Transmission Module Lite (Yahboom)
5V5V
RXDTX0
GNDGND

2. Key Code Analysis

Please refer to the source code in the documentation for specific code.

xxxxxxxxxx
/**
 * @brief Read acceleration in g.
 *        
 */
int IMU_I2C_ReadAccelerometer(float out[3])
{
    uint8_t register_data[6];
    if (read_register(IMU_FUNC_RAW_ACCEL, register_data, 6) != 0) {
        return -1;
    }
    if (out != NULL) {
        float ratio = 16.0f / 32767.0f;
        out[0] = to_int16(&register_data[0]) * ratio;
        out[1] = to_int16(&register_data[2]) * ratio;
        out[2] = to_int16(&register_data[4]) * ratio;
    }
    return 0;
}
​
/**
 * @brief  Read angular velocity in rad/s.
 *       
 */
int IMU_I2C_ReadGyroscope(float out[3])
{
    uint8_t register_data[6];
    if (read_register(IMU_FUNC_RAW_GYRO, register_data, 6) != 0) {
        return -1;
    }
    if (out != NULL) {
        float ratio = (2000.0f / 32767.0f) * (3.1415926f / 180.0f);
        out[0] = to_int16(&register_data[0]) * ratio;
        out[1] = to_int16(&register_data[2]) * ratio;
        out[2] = to_int16(&register_data[4]) * ratio;
    }
    return 0;
}
​
/**
 * @brief Read quaternion (w, x, y, z).
 *        
 */
int IMU_I2C_ReadQuaternion(float out[4])
{
    uint8_t register_data[16];
    if (read_register(IMU_FUNC_QUAT, register_data, 16) != 0) {
        return -1;
    }
    if (out != NULL) {
        out[0] = to_float(&register_data[0]);
        out[1] = to_float(&register_data[4]);
        out[2] = to_float(&register_data[8]);
        out[3] = to_float(&register_data[12]);
    }
    return 0;
}
​
/**
 * @brief Read Euler angles (rad).
 *        
 */
int IMU_I2C_ReadEuler(float out[3])
{
    uint8_t register_data[12];
    if (read_register(IMU_FUNC_EULER, register_data, 12) != 0) {
        return -1;
    }
    if (out != NULL) {
        const float RAD2DEG = 57.2957795f;
        out[0] = to_float(&register_data[0]) * RAD2DEG;
        out[1] = to_float(&register_data[4]) * RAD2DEG;
        out[2] = to_float(&register_data[8]) * RAD2DEG;
    }
    return 0;
}
​
​

IMU_I2C_ReadAccelerometer(): Read acceleration data (unit g)

IMU_I2C_ReadGyroscope(): Reads angular velocity (in rad/s)

IMU_I2C_ReadQuaternion(): Reads quaternions

IMU_I2C_ReadEuler(): Reads Euler angles (in radians)

3. Reading IMU Data

The bin file generated by the ESP32S3 programming example. Open the ESP32S3 programming tool, configure it as shown in the image below, and click the [START] button to download the bin file to the ESP32S3 development board.

image-20251023212928150

After the program is downloaded to the ESP32, open the serial port assistant (configuration parameters are shown in the image below). You can see the IMU module data being continuously printed. When we change the attitude of the IMU module, the data will change.

Note: The above data is from a 10-axis IMU, 6-axis data without magnetometer and barometer, and 9-axis data without barometer.

For MSPM0G3519
For Arduino

COMPANY

  • About us
  • Team Style
  • Blog

LEARNING & EXPLORATION

  • Tutorials
  • Edge AI hardware
  • Educational robots
  • Embedded intelligent hardware

WHERE TO BUY

  • Yahboom Online Store
  • Amazon
  • Alibaba
  • AliExpress
  • Mercado

TECHNOLOGY SUPPORT

  • Email: support@yahboom.com

BE A DISTRIBUTOR

  • Email: sales@yahboom.com
QR Code
QR Code

Copyright © 2017-2026 Yahboom. All Rights Reserved.

EN/中文