Hello. I am finding that a digital compass is very complicated. Is there a example (using Annex) to achieve this, using a affordable module like the MPU9250 or QMC5883L?
Thanks
Zim
code for compass output in degrees from MPU-9250
-
- Posts: 222
- Joined: Mon Feb 15, 2021 1:44 pm
- Has thanked: 126 times
- Been thanked: 132 times
Re: code for compass output in degrees from MPU-9250
If you stretch the 'affordable' a bit, the BNO055 gives a direct readout of heading from Annex. The module is nearly 30 quid.
I'm using one in a device to attach to an astronomical telescope to assist aligning the 'scope to a selected object in the sky (planet, star, galaxy, nebula etc) in a PC program (Stellarium) via its API. I'm reading bearing (azimuth) and pitch (altitude) from the BNO055
It has a target type sight showing on an ESP32 TTGO-Display module so align the dot in the middle of the screen by moving the 'scope and you're pointing at the object in the sky you want to see.
Brilliant in theory, but in practice having a large metal tube at varying angles in close proximity to the compass module plays merry hell with the calibration. Even with an extender to about 1 foot above the 'scope tube accuracy still suffers. Work continues.
I'm using one in a device to attach to an astronomical telescope to assist aligning the 'scope to a selected object in the sky (planet, star, galaxy, nebula etc) in a PC program (Stellarium) via its API. I'm reading bearing (azimuth) and pitch (altitude) from the BNO055
It has a target type sight showing on an ESP32 TTGO-Display module so align the dot in the middle of the screen by moving the 'scope and you're pointing at the object in the sky you want to see.
Brilliant in theory, but in practice having a large metal tube at varying angles in close proximity to the compass module plays merry hell with the calibration. Even with an extender to about 1 foot above the 'scope tube accuracy still suffers. Work continues.
- cicciocb
- Site Admin
- Posts: 2095
- Joined: Mon Feb 03, 2020 1:15 pm
- Location: Toulouse
- Has thanked: 450 times
- Been thanked: 1385 times
- Contact:
Re: code for compass output in degrees from MPU-9250
I agree with Andy, the bno055 is certainly a good choice because it contains inside all the processing power to compute the different angles, including the heading.
It is incredible how the prices increased as I payed around 10€ and now it is priced at more than 30€ !
You can also use the MPU9250 (much cheaper) with the Mahony or Madgwick algorithms (see the examples in the help).
In this case, the Yaw angle is the compass information (heading).
Consider that these devices are very sensitive against the external magnetic fields and metallic objects around.
In particular they must be calibrated using the "8-mouvement" and the local magnetic variation must also be taken into account
It is incredible how the prices increased as I payed around 10€ and now it is priced at more than 30€ !
You can also use the MPU9250 (much cheaper) with the Mahony or Madgwick algorithms (see the examples in the help).
In this case, the Yaw angle is the compass information (heading).
Consider that these devices are very sensitive against the external magnetic fields and metallic objects around.
In particular they must be calibrated using the "8-mouvement" and the local magnetic variation must also be taken into account
Re: code for compass output in degrees from MPU-9250
I have used the QMC6310 magnetic sensor recently as a wind direction sensor, It has I2c but I have just used the Analog output but it was very easy to used , very responsive and inexpensive
Re: code for compass output in degrees from MPU-9250
Thanks cicciocb! I had seen that but didn't know "Yaw" was the heading![Local Link Removed for Guests] wrote: [Local Link Removed for Guests]Wed Feb 22, 2023 10:26 am You can also use the MPU9250 (much cheaper) with the Mahony or Madgwick algorithms (see the examples in the help).
In this case, the Yaw angle is the compass information (heading).
Thanks
Zim
Re: code for compass output in degrees from MPU-9250
Hi peridot;[Local Link Removed for Guests] wrote: [Local Link Removed for Guests]Wed Feb 22, 2023 11:49 am I have used the QMC6310 magnetic sensor recently as a wind direction sensor, It has I2c but I have just used the Analog output but it was very easy to used , very responsive and inexpensive
Did the QMC6310 require programming to achieve analog output, or does it work "out of the box"?
Is there a analog output pin on the module?
Thanks
Zim
- Electroguard
- Posts: 886
- Joined: Mon Feb 08, 2021 6:22 pm
- Has thanked: 285 times
- Been thanked: 329 times
Re: code for compass output in degrees from MPU-9250
This similar item suggests it has a simple analog out... https://www.aliexpress.com/item/4000861 ... Fy4L6KFRL5
Re: code for compass output in degrees from MPU-9250
Thanks Electroguard. I will order one of those too![Local Link Removed for Guests] wrote: [Local Link Removed for Guests]Wed Feb 22, 2023 4:18 pm This similar item suggests it has a simple analog out... https://www.aliexpress.com/item/4000861 ... Fy4L6KFRL5
Thanks
Zim
- Electroguard
- Posts: 886
- Joined: Mon Feb 08, 2021 6:22 pm
- Has thanked: 285 times
- Been thanked: 329 times
Re: code for compass output in degrees from MPU-9250
Yep, I just ordered a couple myself... thanks for bringing the matter to our attention, Peridot.
It looks like the sensor comes with a small magnet, how far from the rotation axis did you mount yours, and any other tips ?
It looks like the sensor comes with a small magnet, how far from the rotation axis did you mount yours, and any other tips ?
- Electroguard
- Posts: 886
- Joined: Mon Feb 08, 2021 6:22 pm
- Has thanked: 285 times
- Been thanked: 329 times
Re: code for compass output in degrees from MPU-9250
Gonna be using one ADC input for wind direction, so might as well try using another for wind speed ... won't break the bank even if it doesn't work.
https://www.aliexpress.com/item/1005003 ... ec%21FR%21
https://www.aliexpress.com/item/1005003 ... ec%21FR%21