M5 Stick C Plus2 - I dont seem to be getting pitch/roll/yaw



  • Hi, I'm very much a novice at this sort of thing but I'm having trouble getting the pitch/roll/yaw data from the StickCPlus2.

    The example file is missing this crucial detail. From what I can tell so far, the Accellerometer data, and the Gyro data is working fine, as per that example at
    https://github.com/m5stack/M5StickCPlus2/blob/master/examples/Basic/imu/imu.ino
    and that's all working great.

    but there's an obvious missing chunk in the example code related to rotational position, and so I looked at the earlier (M5StickCPlus) for clues
    https://github.com/m5stack/M5StickC-Plus/blob/master/examples/Basics/IMU/IMU.ino

    Now here we have a totally different approach, and so I blundered through migrating it a bit, past several errors - until I realised that my Plus2 is very different and relies more on M5Unified

    So I took a look at the integrated example there (in /M5Unified) and it's all very familiar from the Plus2 example except ...
    https://github.com/m5stack/M5Unified/blob/master/examples/Basic/Imu/Imu.ino
    at line 258 where the "mag" vars and array is clearly referenced, where it's missing from the Plus2 example.

    So on my Plus2 if I do something like is implied at line 258 of that file (IE:)

    M5.Lcd.printf("ACCEL %0.2f %0.2f %0.2f\r\n", data.accel.x, data.accel.y, data.accel.z);
    M5.Lcd.printf("GYRO %0.2f %0.2f %0.2f\r\n", data.gyro.x, data.gyro.y, data.gyro.z);
    M5.Lcd.printf("MAG %0.2f %0.2f %0.2f\r\n", data.mag.x, data.mag.y, data.mag.z); // this is the problem

    what I get is something very like the below image, where no rotational attitude data is available.

    So, can you advise where I'm going wrong here? How do I access the equivalent of line 65 in the older example

    M5.Lcd.printf(" %5.2f %5.2f %5.2f ", pitch, roll, yaw);

    missing rotational data

    Where am I going wrong here?

    thanks in advance!



  • Well, I go the M5Unified example working. I'm not sure why I failed on that yesterday, nor which element in there causes it to function correctly where the simple test (above) fails. But I'm accepting the win and absorbing the nicer code into mine. 😉