Home>

MPU6886 works with M5stickC, but not with M5stickC Plus.

'class M5StickCPlus' has no member named'MPU6886'
Corresponding source code
#include<M5StickCPlus.h>
#include<BleKeyboard.h>
BleKeyboard bleKeyboard;
float accX = 0;
float accY = 0;
float accZ = 0;
void setup () {
  Serial.begin (115200);
  M5.begin ();
  bleKeyboard.begin ();
  M5.MPU6886.Init ();
  delay (1000);
}
void loop () {
  if (bleKeyboard.isConnected ()) {
    M5.MPU6886.getAccelData (&accX,&accY,&accZ);
    if ((accX * 1000)<-400) {
      Serial.println ("Sending Page UP key ...");
// bleKeyboard.write (KEY_PAGE_UP);
      delay (100);
    }
    if ((accX * 1000)>400) {
      Serial.println ("Sending Page DOWN key ...");
// bleKeyboard.write (KEY_PAGE_DOWN);
      delay (100);
    }
  }
  else else
    Serial.println ("Keyboard is not Connected");
  delay (5000);
}
What I tried

Refer to hereI tried rewriting it to M5.IMU, but it doesn't seem to work.

M5.IMU.getAccelData (&accX,&accY,&accZ);
  Serial.println ("X is:" + String (accX * 1000) + "Y is:" + String (accY * 1000) + "Z is:" + String (accZ * 1000));


Result: X is: 0.00 Y is: 0.00 Z is: 0.00

Supplementary information (FW/tool version, etc.)

M5stickC Plus
Win10
Arduino IDE 1.8.13

  • Answer # 1

    Switch sciencen page M5StickC Plus The explanation is written in "Please download the library for M5StickC Plus, rewrite the header file to M5StickCPlus.h and compile, etc., and make timely changes."

    For M5StickC PLUS says "Go to this page M5StickCPlus to download the library, add" M5StickC-Plus.zip "to Arduino library folder".

    Did you download the library for M5StickC Plus ("M5StickC-Plus.zip") and put it in the library folder?

  • Answer # 2

    M5.IMU.Init ();


    I found that I had to use first.
    When I actually wrote it, I was able to get the value of IMU (MPU6886).