I purchased the LSM9DS1TR 9-DOF breakout module but cannot get it to correctly display compass direction and cardinal points. I tried the included example but the module does not seem to work properly.
Original message (Croatian)
Pozdrav, kupio sam ovaj modul kod vas: Accelerometer & Gyroscope & Magnetometer LSM9DS1TR 9-DOF breakout , i nikako ne mogu skužiti kako da mi ispravno pokazuje sjever i ostale strane svijeta. Probao sam primjer koji je priložen ali kao da modul ne radi ispravno… Ako mi možete poslati kod koji radi. Hvala
Originally submitted via email support on 14 January 2025. Migrated to the forum for community visibility.
The printAttitude function prints ‘heading’ which contains the relative rotation relative to north:
Upload this example to the microcontroller connected to the breakout via I2C (or easyC cable), and by viewing the Serial monitor at 115200 baud, the ‘Heading :’ output should correctly display the compass direction. If there are problems with initialization of the breakout, this will be caught in the setup() function. Which microcontroller are you using?
I tested that code. I am receiving data, but the data makes no sense - in fact, in one direction the values are suddenly nonlinear. I researched this and apparently soft iron and hard iron calibration is needed, but that did not help either. Additionally, there is a problem with the module itself: after approximately 1-6 minutes of observing serial data (while rotating the module around its axes), my PC displays a blue screen and reboots. This does not happen on an older laptop, only on the new one - the new one probably has protection against high current draw. Could you check this with an oscilloscope or similar? I am using a Dasduino Connect Plus.
Original message (Croatian)
probao sam taj kod, i evo danas opet. No dobivam ja podatke, no opet nikakve smislene podatke, čak štoviše na jednu stranu su naglo nelinearni. Malo sam istraživao o tome, i navodno treba napraviti nekakvu soft iron i hard iron kalibraciju, no ni to nije pomoglo. Nadalje, problem je i sa samim modulom, nakon cca 1 - 6minuta promatranja serial podataka (dok vrtim modul okolo po osima), dođe mi plavi BSOD i reboota mi se PC… Na starom laptopu mi se to ne događa, samo na novom - novi vjerojatno ima zaštitu od velike struje, pa ako možete provjeriti i to, sa osciloskopom ili sl. Koristim dasduino connect plus.
Digital compasses typically use data from multiple sources (such as accelerometer, gyroscope, magnetometer, and on a mobile phone also GPS) to accurately calculate compass direction. In this case, using only one IC that takes isolated measurements, perfectly accurate north direction cannot be guaranteed. Accelerometer readings must be included in the calculation to improve compass heading accuracy.
The recommended approach:
Use a physical compass as a reference
Run the example sketch on the breakout module that outputs measurement data
Record the measured values for different rotations of the device
Based on this data, create a graph and find a formula for calculating compass heading
This can be achieved using the arduino.map function and calculations that should be done manually since it is not part of the driver
It is important to be careful when using gyroscope on a breadboard – metal pins on the breadboard can affect readings and reduce measurement accuracy, so it is best to have the breakout on a table rather than on a breadboard.
Regarding the blue screen problem, we believe the issue is not related to power supply, but potentially related to the CH340 serial bridge driver. We recommend reinstalling the driver according to these instructions:
I expected a simpler working principle since there is a complete library for this. In the end, perhaps it would be better to use a physical compass and a camera for detecting needle position.
Maybe you should compare your module with SparkFun’s to see if there might be a problem with yours?
Original message (Croatian)
neznam, očekivao sam ipak nešto jednostavniji princip rada, pošto postoji cijeli library za to… Na kraju, možda bi bilo bolje koristiti pravi kompas i kameru za detekciju pozicije igle…
Nije mi radio taj driver na win11, pa sam tu našao neke upute CH340 Driver Installation Failure Windows 11 - IDE 1.x - Arduino Forum i instalirao od proizvođača: Nanjing Qinheng Microelectronics Co., Ltd. Možda da usporedite vaš modul i ovaj od sparkfuna, da se vidi jel možda neki problem u vašem?
The working principle and library exist. Our library uses the open-source library from SparkFun. The issue is that this IC, although it has gyroscope and accelerometer capabilities, does not natively have a compass. I researched and found this project on the Adafruit page:
I recommend you review the tutorial to see how it is assembled - it also uses LSM9DS1 as a compass.
This code can be used as a basis for developing a compass for the Arduino platform. The tutorial even has information on how to perform calibration.
Regarding the CH340 driver, if it is installed and code can be uploaded via USB, everything should be OK. If only Dasduino and LSM breakout are connected, the likelihood of current increase is small. If it is part of a larger circuit, please verify the circuit.