pdf-icon

Arduino Quick Start

2. Devices & Examples

6. Applications

Fire IMU 6-Axis Attitude Sensor

APIs and example programs related to the Fire IMU six-axis attitude sensor.

Example Program

Compilation Requirements

  • M5Stack board manager version >= 3.2.2
  • Board option = M5Fire
  • M5Unified library version >= 0.2.8
  • M5GFX library version >= 0.2.11
cpp
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23
#include <M5Unified.h> m5::imu_data_t imuData; void setup() { M5.begin(); M5.Display.setFont(&fonts::FreeMonoBold9pt7b); M5.Display.clear(); M5.Display.setCursor(0, 0); M5.Display.print("IMU Live Data"); } void loop() { M5.Imu.update(); imuData = M5.Imu.getImuData(); M5.Display.setCursor(0, 30); M5.Display.println(" x y z"); M5.Display.printf("Acce % 6.2f, % 6.2f, % 6.2f\n", imuData.accel.x, imuData.accel.y, imuData.accel.z); M5.Display.printf("Gyro % 6.2f, % 6.2f, % 6.2f\n", imuData.gyro.x, imuData.gyro.y, imuData.gyro.z); delay(100); }

Run Result:

API

The Fire IMU 6-axis attitude sensor uses the IMU_Class from the M5Unified library. For more related APIs, please refer to the following documentation:

On This Page