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

    M5Stack fire gyro mpu6050

    PROJECTS
    2
    3
    8.3k
    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.
    • I
      ItHasU
      last edited by

      Hello,

      I just received my M5 Fire + m5bala this morning.
      The M5 fire device is great. I played with M5 library with success (from Arduino) and managed to get some Hello world and other stuff running.

      My problem is when I run the m5bala sample.
      I did managed to compile and upload the sample, but the code won't work.

      After some debugging, it appears that I can drive the motors correctly by setting manual commands.
      However, the MPU6050 seems to be not responding as expected since I always have zero values.

      Here is a piece of code I use to test the MPU. I tried different versions of MPU6050 library with no difference.
      Any help is welcome, thank you.

      Regards

      #include <M5Stack.h>
      #include <MPU6050_tockn.h>
      #include <Wire.h>

      MPU6050 mpu6050(Wire);

      void setup()
      {
      // Power ON Stabilizing...
      delay(500);
      M5.begin();
      M5.setPowerBoostKeepOn(false);

      Wire.begin();
      Wire.setClock(400000UL);  // Set I2C frequency to 400kHz
      
      mpu6050.begin();
      mpu6050.calcGyroOffsets(false);
      //mpu6050.setGyroOffsets(-2.70, -1.08, 0.87);
      
      M5.Lcd.setTextFont(2);
      M5.Lcd.setTextColor(TFT_WHITE, TFT_BLACK);
      M5.Lcd.println("M5Stack Balance Mode start");
      

      }

      void loop()
      {
      mpu6050.update();
      M5.Lcd.clear();
      M5.Lcd.setCursor(0, 0);
      M5.Lcd.printf("X: %f", mpu6050.getAngleX());
      M5.Lcd.setCursor(0, 20);
      M5.Lcd.printf("Y: %f", mpu6050.getAngleY());
      M5.Lcd.setCursor(0, 40);
      M5.Lcd.printf("Z: %f", mpu6050.getAngleZ());
      delay(500);
      // M5 Loop
      M5.update();
      }

      1 Reply Last reply Reply Quote 0
      • ajb2k3A
        ajb2k3
        last edited by

        This post is deleted!
        1 Reply Last reply Reply Quote 0
        • I
          ItHasU
          last edited by

          Ok, it seems that the problem was due to my version of ESP32 tools.
          I updated my ESP32 framework and now the code is working fine.

          Also, I used PlatformIO in VSCode which make things simpler since it enables the M5STACK_FIRE flag during compilation.

          1 Reply Last reply Reply Quote 0
          • First post
            Last post