English
English
简体中文
日本語
pdf-icon

Arduino Quick Start

2. Devices & Examples

5. Extensions

6. Applications

Atom-Lite/Atom-Matrix IMU Six-axis Attitude Sensor

APIs and example sketch for the Atom-Lite / Atom-Matrix six-axis IMU.

Example

Compilation Requirements

  • M5Stack Board Manager version >= 3.2.6
  • Development board option = M5Atom
  • M5Unified library version >= 0.2.13
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();
  Serial.begin(115200);
}

void loop() {
  M5.Imu.update();
  imuData = M5.Imu.getImuData();

  Serial.printf("\n Acc X = %6.2f  \n", imuData.accel.x);
  Serial.printf(" Acc Y = %6.2f  \n", imuData.accel.y);
  Serial.printf(" Acc Z = %6.2f  \n\n", imuData.accel.z);

  Serial.printf(" Gyr X = %6.2f  \n", imuData.gyro.x);
  Serial.printf(" Gyr Y = %6.2f  \n", imuData.gyro.y);
  Serial.printf(" Gyr Z = %6.2f  \n", imuData.gyro.z);

  delay(1000);
} 

The sketch prints real-time accelerometer and gyroscope readings to the serial console once per second.

API

The IMU on Atom-Lite / Atom-Matrix is provided by the Imu_Class in the M5Unified library. For more details see:

On This Page