Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How do I use the BNO055 COMPASS_MODE to determine compass heading? #100

Open
KingFuGitHub opened this issue Apr 1, 2022 · 1 comment
Open

Comments

@KingFuGitHub
Copy link

I saw that there is a compass mode for the BNO055 in the https://circuitpython.readthedocs.io/_/downloads/bno055/en/5.1.0/pdf/ documentation. Furthermore, I would love to know how to turn on that mode so that I can use the magnetometer to determine the compass heading direction. For example, print("Heading: " + str(180+math.tan2(sensor.magnetic[1], sensor.magnetic[0])*180/math.pi). Currently, I am using that to determine the heading but it fluctuate a lot and it's not consistent. Thanks in advance.

@tekktrik
Copy link
Member

tekktrik commented Apr 2, 2022

It looks like COMPASS MODE isn't currently set up for the library, but you should be able to manually do it for now this way:

import time
import board
import adafruit_bno055

i2c = board.I2C()
sensor = adafruit_bno055.BNO055_I2C(i2c)

# Set the sensor to mode manually
sensor.mode = 0x09

# Read the registers without help of methods
values = sensor._magnetic

I don't have the sensor so I can't test it, but that shoooouuuld be it. I think this would could be a great addition to the library. The mode would just need to be added and then the magnetic property would to allow returning the results if it is in COMPASS MODE. If you're up for it, you can submit a pull request!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants