Using BMM270 Accel/Gyro and BMI150 Magnetomer Sensors with Teensy 4.x

Tried imu.begin(&Serial) and did not get any output. Since you ordered one, the first hangup I hit is trying to use Wire but the M5 library has it setup for external i2c devices. Wire1 works for the internal i2c.
 
Tried imu.begin(&Serial) and did not get any output. Since you ordered one, the first hangup I hit is trying to use Wire but the M5 library has it setup for external i2c devices. Wire1 works for the internal i2c.
Was wondering about that when I saw it in firmware for the m5stack - didn't see it on the schematic though.
 
@russellkt
Received my Atoms3r and been playing with it. Finally got it figure out. But for some documentation of whats going on.

1. Took apart the case to determine chip orientation instead of guessing.
1734872406667.png

2. Looking at the datasheets for pin1 /axis orientation and putting in NED Coordinates gives the following conversion

C++:
   // Match axis orientation from example
   val[0] = -ay;
   val[1] = -ax;
   val[2] = -az;
  
   val[3] = -gy ;
   val[4] = -gx ;
   val[5] = -gz ;
  
   val[6] = mx / 10.0f;
   val[7] = my / 10.0f;
   val[8] = mz / 10.0f;

3. But to do item 2 you have to edit the imu_class.cpp file in m5unified/src/utility directory
change it (about line 89) to
C++:
#if defined ( CONFIG_IDF_TARGET_ESP32S3 )
        if (board == m5::board_t::board_M5StackCoreS3 && bmi2->getAddress() == 0x69)
        {  // CoreS3 では、地磁気のY軸Z軸をそれぞれ反転する
          _internal_axisorder_fixed[sensor_index_mag] = (internal_axisorder_t)(axis_invert_y | axis_invert_z); // Y軸,Z軸反転
        } else
        if (board == m5::board_t::board_M5AtomS3R || board == m5::board_t::board_M5AtomS3RCam || board == m5::board_t::board_M5AtomS3RExt)
        { // AtomS3Rシリーズ では、ジャイロと加速度のY軸とX軸を入れ替え、Y軸を反転するほか、地磁気のX軸とZ軸をそれぞれ反転する
        //Then, the gyro and acceleration Y-axis and X-axis are swapped, and the Y-axis is reversed, and the X-axis and Z-axis of the geomagnetic field are reversed, respectively
        //  _internal_axisorder_fixed[sensor_index_accel] = (internal_axisorder_t)(axis_order_yxz | axis_invert_y);
        //  _internal_axisorder_fixed[sensor_index_gyro ] = (internal_axisorder_t)(axis_order_yxz | axis_invert_y);
        //  _internal_axisorder_fixed[sensor_index_mag  ] = (internal_axisorder_t)(axis_invert_x | axis_invert_z); // X-axis, Z-axis inversion
        _internal_axisorder_fixed[sensor_index_accel] = (internal_axisorder_t)(axis_order_xyz);
       _internal_axisorder_fixed[sensor_index_gyro ] = (internal_axisorder_t)(axis_order_xyz);
      _internal_axisorder_fixed[sensor_index_mag  ] = (internal_axisorder_t)(axis_order_xyz ); // X-axis,
        }
#endif
Notice I commented what was there just to keep track. Probably easier way to do but at least it works for now.

Then after updating the sketches I put together (will make them attachments)
Motion gives
Screenshot 2024-12-22 074514.png


For acceleration I used 6point cal: which gives

Code:
Accel X Bias:         0.046889
Accel X Scale Factor: 1.001222
Accel Y Bias:         0.046889
Accel Y Scale Factor: 1.003922
Accel Z Bias:         0.040066
Accel Z Scale Factor: 0.997322

And fusion then becomes stable and compass is now working.
Screenshot 2024-12-22 075003.png



Files so you can play are now attached

Cheers Mike
 

Attachments

  • M5_BMI270_BMM150_Fusion.zip
    5.2 KB · Views: 16
  • M5CalAnalysisBochBMI270_BMI150.zip
    9.3 KB · Views: 15
  • M5_bmi270_motioncal.zip
    3.7 KB · Views: 12
  • M5_Bmi270_basic_data.zip
    969 bytes · Views: 15
Thank you so much and looking forward to playing. Really like the form factor and with your help think I can get it working!!
 
I did and got the following in MotionCal:

1734973894481.png


All looks good. Also went with the six point calibration and got:

1734973956885.png


I did not use the magnetometer scale factor/bias.

However, when I show in imu3 all looks ok but after a yaw movement, it will reach a position, and then drift away when holding steady. Created the attached sketch and heading is all over the place.
 

Attachments

  • atom_fusion_compass.ino
    2 KB · Views: 16
However, when I show in imu3 all looks ok but after a yaw movement, it will reach a position, and then drift away when holding steady. Created the attached sketch and heading is all over the place.
Strange - mine was steady.

PS looked at your sketch and did see where you included the accel caibration. You also didn't include a few things that you need. Will give it try a bit later - have a few things to do outside programming right now.
 
Ok finally finished playing. Give this sketch a try - also draws a compass.

NOTE Updated sketch
1735067525296.jpeg
 

Attachments

  • M5_atoms3r_compass_v2-241224a.zip
    4 KB · Views: 11
Last edited:
@russellkt

Spent some more time on this and got my library working with the AtomS3R. All files for using the Library with the S3R and the files for working with the builtin lib have been posted to:

 
@russellkt

Spent some more time on this and got my library working with the AtomS3R. All files for using the Library with the S3R and the files for working with the builtin lib have been posted to:

Cannot express how thankful I am for all of your work. Tied up with kids at Christmas today but hopefully can get some time tonight or tomorrow.

Thank you again and Happy Holidays!!
 
Sorry for the delay. Thank you again for all of your work! Unfortunately, I adjusted the orientation in the m5 library, calibrated the atom using motioncal, inputted the values, and am still getting very sketchy results. Compass only goes between ~150 and ~190 degrees. At this time, I'm I will probably abandon for the time being until I can get another one to rule out any board or sensor issues.
 
Sorry for the delay. Thank you again for all of your work! Unfortunately, I adjusted the orientation in the m5 library, calibrated the atom using motioncal, inputted the values, and am still getting very sketchy results. Compass only goes between ~150 and ~190 degrees. At this time, I'm I will probably abandon for the time being until I can get another one to rule out any board or sensor issues.
Thats strange seems to be working for me. Did you use the updated sketches I had for MotionCal?
 
Back
Top