🤖Have you ever tried Chat.M5Stack.com before asking??😎
    M5Stack Community
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Register
    • Login

    How to get an IMU MPU6886 work at M5Paper?

    Scheduled Pinned Locked Moved Arduino
    2 Posts 1 Posters 3.7k Views
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • H Offline
      herb
      last edited by herb

      I tried to get an M5 Stack MPU6886 to work on my M5Paper Unit. But without success.

      What did I do?

      Connected the IMU MPU6886 to Port A.

      modified the example Code from M5 to the following

      #include <M5EPD.h>
      #include "time.h"
      
      #ifdef __cplusplus
      extern "C"
      {
        #include "IMU_6886.h"
      }
      #endif
      
      IMU_6886 imu6886;
      
      float accX = 0;
      float accY = 0;
      float accZ = 0;
      
      float gyroX = 0;
      float gyroY = 0;
      float gyroZ = 0;
      
      char string_buff[40];
      
      float temp = 0;
      
      void setup() {
        // put your setup code here, to run once:
        M5.begin();
        imu6886.Init(25, 32);
      
        
      }
      
      void loop() {
        // put your main code here, to run repeatedly:
        imu6886.getGyroData(&gyroX,&gyroY,&gyroZ);
        Serial.print("gyroX: ");
        Serial.println(gyroX);
        imu6886.getAccelData(&accX,&accY,&accZ);
        Serial.print("accX: ");
        Serial.println(accX);
        imu6886.getTempData(&temp);
        Serial.print("Temp: ");
        Serial.println(temp);
        delay(1000);
      }
      

      At the first line I changed M5EPD.h instead of M5Stack.h and changed I2C Port to 25/32

      The same within IMU_6886.cpp .

      Comparing M5EPD.h to M5Stack.h, the M5EPD has no I2C Class Reference to CommUtil .
      So I added these two lines into M5EPD.h together with an #include "utility/CommUtil.h" at the beginning of the code.

          Button BtnR = Button(M5EPD_KEY_RIGHT_PIN, true, 10);
      
          // I2C
          CommUtil I2C = CommUtil();
      
          M5EPD_Driver EPD = M5EPD_Driver();
      

      CommUtil.h and CommUtil.cpp I copied from M5Stack/src/utility to the corresponding path of M5EPD.
      Within CommUtil.cpp I changed the include also to ../M5EPD.h".

      After doing these steps the Compiling process ends without any errors and I can upload the sketch to the unit.

      Looking at the serial monitor it does not display any valid values. Only 25 Temperature but it's not changing and the other values are zero.

      Doeas anyone have an example code for IMU6886 running together with M5 Paper or can give me some hints to get the example code for m5Stack working on M5Paper?

      Regards Herb

      1 Reply Last reply Reply Quote 0
      • H Offline
        herb
        last edited by

        I switched over to this library https://github.com/tanakamasayuki/I2C_MPU6886

        There is no modification of the EPD Library necessary. Now it works with there example code.

        1 Reply Last reply Reply Quote 0

        Hello! It looks like you're interested in this conversation, but you don't have an account yet.

        Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.

        With your input, this post could be even better 💗

        Register Login
        • First post
          Last post