BNO055 magnetometer calibration status

My BNO055 magnetometer is connected to a Pi Zero, and I have managed to obtain data when running the code (bno055_simpletest.py) copied from from https://learn.adafruit.com/adafruit-bno055-absolute-orientation-sensor/python-circuitpython. I have tried to read the self calibration status from the sensor’s register address 35, but have not had any luck due to my very limited programming knowledge. Could anybody help me with this issue?
Ideally, I’d also like to reconfigure the sensor to be positioned upright, and save the calibration offset data for future use; any help would also be appreciated!

2 Likes

Hi Richard,

No worries, we should just do a quick check to make sure that it’s in the correct address. (I assume that you’re using I2C) If you run i2cdetect -y 1 in the terminal, that should provide an output to confirm the address of your magnetometer. Also, I’ve been looking through the Repos on Github. The quick and easy method I can think of is to store the offset information in a plain text file and then pull and overwrite that as necessary from a custom wrote python script, otherwise, the other option is to modify the library itself with a hardcoded offset or to pull it from local storage every time it runs, but the latter would be much harder to do I’d imagine, although this will streamline the usage of this functionality in your future projects. As always, if you have a suggestion for a feature in their script you can add it to the creator’s repo, from there, they may add it in the future if it’s possible.

3 Likes

Thanks Bryce for your very quick response. I will try your suggested library code (read_all_data.ino), and hope that I can extract just a few of these 140 lines to read only the calibration status. It seems that saving the calibration data for re-use is beyond my capability; my best hope is to find someone who has already documented process.

1 Like

Bryce, unfortunately the caibration status code you suggested (read_all_data.ino) appears to be Arduino/C++ (?), wheras my project uses Python on a R Pi Zero.
I had found https://github.com/adafruit/Adafruit_CircuitPython_BNO055/blob/master/adafruit_bno055.py , which appears to be similar to Python; it is 820 lines, and does’nt seen to run on my Pi either.

1 Like

I managed to get the calibration status by just inserting the following row below While True: in my existing code (bno055_simpletest.py) : print(“Cal status (S,G,A,M): {}”.format(sensor.calibration_status))

Interestingly, it took about a minute for the 4 sections of the BNO055 to achieve full calibration status when moving the sensor around randomly. However in my case, nearby hard and soft iron project components still cause about 5 degrees of magnetometer/Euler heading error despite calibration. This error is similar to a more basic 6DOF sensor used previously, such as LSM303D, after manual calibration.

I will try to find Python code to convert the BNO055 Quaternion sensor data to Euler angles to see if this data any more accurate. But I believe this only happens if the sensor is not horizontal.

2 Likes

Using BNO055’s Quaternion instead of Euler data for heading improves accuracy in certain orientations. My “beginner-modified” simpletest.py code for quaternion derived yaw (qyaw) is pasted below (thanks to Adafruit & toptechboy.com).

I’m still hoping to find help with python code to save and re-load BNO055 calibration data.

3 Likes

Hi Richard,

Which section was that in? The Repo I linked to should be in Python. As for modifying the script you’ve got, I’d check out the tutorial below, should be easy enough to add some lines to the script you’ve already got to save and then access your calibration data as needed if you can directly access those values in your script.

1 Like

Thanks Bryce. My reference above to read_all_data.ino came from https://github.com/adafruit/Adafruit_BNO055/blob/master/examples/read_all_data/read_all_data.ino , but that was in the context of get calibration code, which has been solved. I’ll try your suggested tutorial, or may need look for another sensor which has similar performance without needing to be recalibrated (BNO085?)

1 Like

Good morning Richard,

Thanks for your call, here’s the datasheet you requested regarding the BNO085. Please let me know if there’s anything else that you need.