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

    ATOMS3R accelerometer and gyro readings always 0

    Atom
    5
    6
    180
    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.
    • T
      toffifee
      last edited by

      Hi everyone,
      I bought an ATOMS3R, and burned the UIFlow2.0 ATOMS3R firmware on it. In UIFlow 2.0 I tried to print the accelerometer and gyroscope readings with below code.
      However, the readings are all zero regardless of how I move or shake the ATOM. Did I miss an initialization or calibration step?

      import os, sys, io
      import M5
      from M5 import *
      import time
      
      accel = None
      gyro = None
      
      
      def setup():
        global accel, gyro
      
        M5.begin()
      
      
      def loop():
        global accel, gyro
        M5.update()
        acc_x, acc_y, acc_z = Imu.getAccel()
        gyro_x, gyro_y, gyro_z = Imu.getGyro()
        print(f'accel: {acc_x}x, {acc_y}y, {acc_z}z')
        print(f'gyro: {gyro_x}x, {gyro_y}y, {gyro_z}z')
        time.sleep(1)
      
      
      if __name__ == '__main__':
        try:
          setup()
          while True:
            loop()
        except (Exception, KeyboardInterrupt) as e:
          try:
            from utility import print_error_msg
            print_error_msg(e)
          except ImportError:
            print("please update to latest firmware")
      
      
      1 Reply Last reply Reply Quote 0
      • kurikoK
        kuriko
        last edited by

        @toffifee
        have you tried Arduino example? we can determine if that was a hardware problem
        https://github.com/m5stack/M5AtomS3/blob/main/examples/Basics/imu/imu.ino

        Good morning, and welcome to the Black Mesa Transit System.

        T 1 Reply Last reply Reply Quote 0
        • H
          hacxx
          last edited by

          It looks like you're missing initialization for the IMU sensor. Try adding Imu.begin() inside the setup() function after M5.begin(). Without this, the sensor may not start properly, leading to zero readings. Also, ensure you're using the latest firmware and that the device isn't in USB mode, which can disable sensor updates.

          felmueF 1 Reply Last reply Reply Quote 0
          • felmueF
            felmue @hacxx
            last edited by

            Hello @toffifee

            your code works for me using an M5AtomS3 (non R).

            That said, M5AtomS3 uses a different IMU chip (MPU68860) than M5AtomS3R (BMI270 / BMM150). So my best guess would be that UIFlow2 is not fully adapted to M5AtomS3R (yet).

            @hacxx : FYI @toffifee is using UIFlow2 - there is no Imu.begin().

            Thanks
            Felix

            GPIO translation table M5Stack / M5Core2
            Information about various M5Stack products.
            Code examples

            1 Reply Last reply Reply Quote 0
            • T
              toffifee @kuriko
              last edited by

              Thanks for answering, guys.
              I tried the Arduino example as suggested by @kuriko and indeed I get non-zero readings! So maybe @felmue is right to assume that UIFlow2 doesn't fully support M5AtomS3R yet.

              The IMU readings don't make a lot of sense to me yet, I will next try to calibrate with this example code:

              https://github.com/m5stack/M5Unified/blob/master/examples/Basic/Imu/Imu.ino

              teastainT 1 Reply Last reply Reply Quote 0
              • teastainT
                teastain @toffifee
                last edited by

                @toffifee The raw outputs are beyond the ken of mortal man, except Accel which can easily be observed by placing it on a stationary level surface and observing that the accel values are stationary and one of the axes, usually Z is showing 1.00 (gravity).
                Roll it onto its side and the 1.00 should move to another axis.
                The other two outputs Gyro and Mag are best left to a positioning algorithm.

                Cheers, Terry!

                100% M5Stack addict with several drawers full of product!

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