I recently purchased a 6-axis IMU MCP6886 module by M5Stack. Product link: https://github.com/m5stack/M5-ProductExampleCodes/tree/master/Unit/IMU_Unit. The example code provided by the manufacturer is as follows:
#include "I2C_MPU6886.h"
I2C_MPU6886 imu(I2C_MPU6886_DEFAULT_ADDRESS, Wire1);
void setup() {
Serial.begin(115200);
delay(1000);
Wire1.begin(21, 22);
imu.begin();
Serial.print("whoAmI() = 0x%02x\n", imu.whoAmI());
}
void loop() {
float ax;
float ay;
float az;
float gx;
float gy;
float gz;
float t;
imu.getAccel(&ax, &ay, &az);
imu.getGyro(&gx, &gy, &gz);
imu.getTemp(&t);
Serial.print("%f,%f,%f,%f,%f,%f,%f\n", ax, ay, az, gx, gy, gz, t);
delay(100);
}
When I run this code on Arduino IDE 1.8.19, I get the following error: 'Wire1' was not declared in this scope. I believe this issue is with the I2C_MPU6886 library itself, but I am not able to troubleshoot it. I am using an Arduino Uno R3 board and running the IDE on Windows 11.
1 Answer 1
"M5Stack" is an ecosystem of ESP32 based boards and peripherals.
All code for M5Stack peripherals is written for the M5Stack system. Not for the Uno.
You have to find code for the Uno, not for the M5Stack. M5Stack code will not work on the Uno since it is a completely different system.
I am using an Arduino Uno R3 board
-- so... not an M5Stack...? So why are you using M5Stack code...?