Arduino Quick Start
CoreS3 IMU related APIs and case programs.
#include <M5CoreS3.h> void setup(void) { auto cfg = M5.config(); CoreS3.begin(cfg);} void loop(void) { auto imu_update = M5.Imu.update(); if (imu_update) { CoreS3.Display.setCursor(0, 40); CoreS3.Display.clear(); // Delay 100ms 延迟100ms auto data = M5.Imu.getImuData(); // The data obtained by getImuData can be used as follows. data.accel.x; // accel x-axis value. data.accel.y; // accel y-axis value. data.accel.z; // accel z-axis value. data.accel.value; // accel 3values array [0]=x / [1]=y / [2]=z. data.gyro.x; // gyro x-axis value. data.gyro.y; // gyro y-axis value. data.gyro.z; // gyro z-axis value. data.gyro.value; // gyro 3values array [0]=x / [1]=y / [2]=z. data.mag.x; // mag x-axis value. data.mag.y; // mag y-axis value. data.mag.z; // mag z-axis value. data.mag.value; // mag 3values array [0]=x / [1]=y / [2]=z. data.value; // all sensor 9values array [0~2]=accel / [3~5]=gyro / [6~8]=mag Serial.printf("ax:%f ay:%f az:%f\r\n", data.accel.x, data.accel.y, data.accel.z); Serial.printf("gx:%f gy:%f gz:%f\r\n", data.gyro.x, data.gyro.y, data.gyro.z); Serial.printf("mx:%f my:%f mz:%f", data.mag.x, data.mag.y, data.mag.z); CoreS3.Display.printf("IMU:\r\n"); CoreS3.Display.printf("ax:%f ay:%f az:%f\r\n", data.accel.x, data.accel.y, data.accel.z); CoreS3.Display.printf("gx:%f gy:%f gz:%f\r\n", data.gyro.x, data.gyro.y, data.gyro.z); CoreS3.Display.printf("mx:%f my:%f mz:%f\r\n", data.mag.x, data.mag.y, data.mag.z); } delay(100);}
The M5CoreS3 library is based on the M5Unified library, the IMU part of the driver uses the IMU_Class
in the M5Unified library, for more related APIs you can refer to the following document: