Skip to content

Instantly share code, notes, and snippets.

@dj1711572002
Created May 24, 2021 14:25
Show Gist options
  • Save dj1711572002/27f79698f0326e1b511ea39368bdc2d0 to your computer and use it in GitHub Desktop.
Save dj1711572002/27f79698f0326e1b511ea39368bdc2d0 to your computer and use it in GitHub Desktop.
M5StickC_IMU_Serial.print_5msecPeriod
#include <M5StickC.h>
float accX = 0.0F;
float accY = 0.0F;
float accZ = 0.0F;
float gyroX = 0.0F;
float gyroY = 0.0F;
float gyroZ = 0.0F;
float pitch = 0.0F;
float roll = 0.0F;
float yaw = 0.0F;
void setup() {
// put your setup code here, to run once:
M5.begin();
M5.IMU.Init();
//Serial.setRotation(3);
//Serial.fillScreen(BLACK);
//Serial.setTextSize(1);
//Serial.setCursor(40, 0);
Serial.println("IMU TEST");
// Serial.setCursor(0, 10);
Serial.println(" X Y Z");
//Serial.setCursor(0, 50);
Serial.println(" Pitch Roll Yaw");
}
float temp = 0;
/*****************************************
M5.IMU.getGyroData(&gyroX,&gyroY,&gyroZ);
M5.IMU.getAccelData(&accX,&accY,&accZ);
M5.IMU.getAhrsData(&pitch,&roll,&yaw);
M5.IMU.getTempData(&temp);
*****************************************/
void loop() {
// put your main code here, to run repeatedly:
M5.IMU.getGyroData(&gyroX,&gyroY,&gyroZ);
M5.IMU.getAccelData(&accX,&accY,&accZ);
M5.IMU.getAhrsData(&pitch,&roll,&yaw);
M5.IMU.getTempData(&temp);
//Serial.setCursor(0, 20);
//Serial.printf("%6.2f,%6.2f,%6.2f,", gyroX, gyroY, gyroZ);
//Serial.setCursor(140, 20);
//Serial.print("o/s");
//Serial.setCursor(0, 30);
Serial.printf("%5.2f,%5.2f,%5.2f,", accX, accY, accZ);
//Serial.setCursor(140, 30);
//Serial.print("G");
//Serial.setCursor(0, 60);
Serial.printf("%5.2f,%5.2f,%5.2f,", pitch, roll, yaw);
Serial.println(millis());
//Serial.setCursor(0, 70);
//Serial.printf("Temperature : %.2f C", temp);
//delay(1000);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment