pdf-icon

Arduino Quick Start

PaperS3 IMU (6-axis Attitude Sensor)

PaperS3 IMU related APIs and example programs.

Example Program

Build Requirements

  • M5Stack board manager version >= 2.1.4
  • Board selection = M5PaperS3
  • M5Unified library version >= 0.2.5
  • M5GFX library version >= 0.2.7
cpp
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30
#include <M5Unified.h>
#include <M5GFX.h>
m5::imu_data_t imuData;
void setup() {
M5.begin();
M5.Display.setRotation(0);
M5.Display.setFont(&fonts::FreeMonoBold24pt7b);
M5.Display.clear();
M5.Display.print(" IMU Live Data\n");
}
void loop() {
M5.Imu.update();
imuData = M5.Imu.getImuData();
M5.Display.setCursor(0, 100);
M5.Display.printf(" Acc X = %6.2f \n", imuData.accel.x);
M5.Display.printf(" Acc Y = %6.2f \n", imuData.accel.y);
M5.Display.printf(" Acc Z = %6.2f \n\n", imuData.accel.z);
M5.Display.printf(" Gyr X = %6.2f \n", imuData.gyro.x);
M5.Display.printf(" Gyr Y = %6.2f \n", imuData.gyro.y);
M5.Display.printf(" Gyr Z = %6.2f \n", imuData.gyro.z);
delay(1000);
}

This program will display real-time readings from the accelerometer and gyroscope, refreshing once per second.

API

The attitude sensor of the PaperS3 uses the Imu_Class from the M5Unified library. For more related APIs, please refer to the documentation below:

On This Page