Good morning everyone.
I'm having a problem with a homemade digital compass that uses the BOSCH CMPS12 sensor and the ATMEL ATtiny84 microcontroller. The CMPS12, among its features, also has Z-axis tilt compensation.
The compass, tested in a car, on a wooden table, away from magnets, ferromagnetic materials, and anywhere other than the sea, works perfectly.
When I installed it on my catamaran (a Hobie Cat 16) yesterday and calibrated it, I went out to sea (it was the first time I'd taken the compass with me and participated in a regatta), the compass began providing completely incorrect numbers. For example, if I was sailing northeast (45 degrees), the compass indicated a heading of 220 degrees. When I was facing south, it indicated 10 degrees (the numbers are purely indicative and were never the same).
Even stranger is that, once the course was set, even though the indication was incorrect, it was still stable, and if I deviated by 2 or 3 degrees, the display showed a variation of 2 or 3 degrees.
I installed the compass under the rear bar (which is made of aluminum), a few centimeters from the water (the compass case is made of plexiglass and is watertight), away from ferrous or other objects that could, at least in theory, affect the sensor.
I haven't been able to perform any further navigation tests yet, but I intend to do so as soon as possible. In the meantime, I'd like your help.
One last thing. As soon as we returned to shore, I turned it back on, leaving it installed: the indications returned to normal.
I wonder if the large mass of salt water below, in motion (relative motion), could be the cause.
Thank you all for any help you can give me, and have a good day.
Antonio C. (Italy)
Check the datasheet application notes for warnings, tips etc.
I did: the datasheet shows nothing about the problem I encountered.
No. Based on your vague description, magnetometer calibration, intermittent wiring or power supply problems are the top suspects.
For informed help, more information is needed. Please read and follow the directions in the "How to get the best out of this forum" post. A photo of the setup would help, too.
Regarding calibration, after a few minutes the system tells me everything is fine (register bits 0x24 are all set to 1).
It could be a connection issue or intermittent power supply, but then why does it work perfectly when I leave it in my car, despite all the potholes on Italian roads? And it absorbs a lot of vibrations due to the potholes that Italian roads are full of, much more than it does at sea (I'm not kidding: once, I broke a tire on my car because of those potholes). I've double-checked all the connections, and they're all stable, especially the power supply.
What other information do you need to be able to make a more specific hypothesis?
Many thanks
I gave up on the Bosch sensors years ago, especially the BNO055 (CMPS12), because the built in magnetometer calibration is very crude and works poorly, if at all. This is well documented, and the only way to get Bosch IMUs to work properly is to turn off the automatic calibration, read the raw sensor data, and determine/apply the calibration correction in your application code.
Best overview on magnetometer calibration: Tutorial: How to calibrate a compass (and accelerometer) with Arduino | Underwater Arduino Data Loggers
Example of an actually useful tilt-compensated compass with the BNO055:
https://forums.adafruit.com/viewtopic.php?t=218995
By the way: that sensor is long obsolete and Bosch hasn't sold any in years, so what you have could be anything ranging from legitimate old stock, recycled or reject parts, to outright counterfeit.