Gyroscope generates 0 randomly

Hi,

I am trying to generate a dataset with Arduino Nano 33 BLE Sense. I've realized I get 0 time to time from the gyroscope.

-0.021850586 0.972412109 -0.052978516 -0.366210938 -2.563476563 0.061035156 3.247070313 -46.92382813 -15.77148438
-0.022705078 0.974121094 -0.052124023 -0.122070313 -2.319335938 -0.061035156 3.491210938 -46.77734375 -15.16113281
-0.021240234 0.970458984 -0.052490234 -0.183105469 -2.197265625 0 3.137207031 -47.19238281 -14.59960938
-0.021972656 0.973876953 -0.052734375 -0.244140625 -2.44140625 0 3.430175781 -46.63085938 -14.01367188
-0.020874023 0.973266602 -0.053222656 -0.244140625 -2.502441406 0.061035156 3.198242188 -47.52197266 -14.19677734
-0.021484375 0.973266602 -0.053588867 -0.122070313 -2.319335938 0.183105469 3.576660156 -46.97265625 -13.91601563
-0.021362305 0.972900391 -0.052978516 -0.305175781 -2.319335938 0 2.954101563 -46.92382813 -14.16015625
-0.020996094 0.972290039 -0.053588867 -0.183105469 -2.44140625 0.061035156 2.844238281 -47.02148438 -15.625
-0.022460938 0.974121094 -0.052978516 -0.183105469 -2.502441406 -0.122070313 3.137207031 -47.53417969 -16.66259766
-0.022216797 0.974853516 -0.052856445 -0.366210938 -2.44140625 0 3.308105469 -47.10693359 -14.69726563
-0.021606445 0.973999023 -0.052124023 -0.305175781 -2.380371094 0 3.857421875 -46.89941406 -15.20996094
-0.021606445 0.974365234 -0.052734375 -0.366210938 -2.44140625 0 3.564453125 -46.64306641 -15.73486328

The middle 3 columns are gyroscope data. As you see, accelerometer and magnetometer do not generate any 0's.

I believe I need to calibrate the sensor. I am curious if there is any official way, or Femme's way is the correct way.

The usual way to calibrate the gyroscope is to collect a few hundred points from each axis, while it is sitting still, average those values, and subtract the averages from subsequent readings.

It is also very important to calibrate the magnetometer, if you intend to use it.

Thanks @jremington. I see. Is it the same for magnetometer and accelerometer?

Also sometimes, I am getting random peaks as shown in below figure.

What might be the reason for those?

What do the lines on the graph represent?

Tutorial on magnetometer/accelerometer calibration: Tutorial: How to calibrate a compass (and accelerometer) with Arduino | Underwater Arduino Data Loggers

Many thanks for the tutorial. They are gyroscope data.

if (IMU.gyroscopeAvailable()) {
    IMU.readGyroscope(x1, y1, z1);
    Serial.print(",");
    Serial.print(x1, 11);
    Serial.print(",");
    Serial.print(y1, 11);
    Serial.print(",");
    Serial.println(z1, 11);
}

I have found the reason, currently I am looking for the solution.

The reason is that above the example code I shared, I query magnetometer data at the same time as well.

IMU.readMagneticField(x2, y2, z2);

If I do not query, I do not get any peaks as seen below.
arduinoGyroPlotSolo
I tested with accelerometer, and it is fine. So in summary, we can get accelerometer & gyroscope data at the same time without any issues. But if we add magnetometer data, we will have those peaks.

I am currently looking at the source code to understand the reason.

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.