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

feather_sense_sensor_demo.ino (using Adafruit_LIS3MDL.h) #2448

Open
MdeLv opened this issue Mar 20, 2023 · 1 comment
Open

feather_sense_sensor_demo.ino (using Adafruit_LIS3MDL.h) #2448

MdeLv opened this issue Mar 20, 2023 · 1 comment

Comments

@MdeLv
Copy link

MdeLv commented Mar 20, 2023

Board: FeatherSense
Magnetometer : LIS3MDL.
SW: feather_sense_sensor_demo.ino
Library: Adafruit_LIS3MDL.h

The sw (.ino) computes with this board and library a maximum "magnetic field" of approx 2,000 uT, while this should be 20,000-40,000 uT depending on the orientation of the board/sensor (horizontal towards North, vertical).

You read x, y, z which are raw measures:
Adafruit_LIS3MDL.h#L106

int16_t x,     ///< The last read X mag in raw units
      y,         ///< The last read Y mag in raw units
      z;         ///< The last read Z mag in raw units
  float x_gauss, ///< The last read X mag in 'gauss'
      y_gauss,   ///< The last read Y mag in 'gauss'
      z_gauss;   ///< The last read Z mag in 'gauss'

While you use x, y, z in uT:
feather_sense_sensor_demo.ino L60

  lis3mdl.read();
  magnetic_x = lis3mdl.x;
  magnetic_y = lis3mdl.y;
  magnetic_z = lis3mdl.z;

See feather_sense_sensor_demo.ino#L101

  Serial.print("Magnetic: ");
  Serial.print(magnetic_x);
  Serial.print(" ");
  Serial.print(magnetic_y);
  Serial.print(" ");
  Serial.print(magnetic_z);

1/ Can you check how you came to write mag field unit in uTesla?
2/ How do you convert raw sensor measures (that are used) to measures in uT (while measures are in Gauss, according to the ST technical documentation and according to the library)?

In fact, it appears that the .ino program should simply use x_gauss, y_gauss, z_gauss instead of x, y, z, and should convert measures from G to uT (* 10E-4 * 10E6 i.e. * 10E2 uT).
I'll check that these two changes provide realistic as well as accurate measurements.

Anyway, the .ino program needs to be updated to display measures in uT.
Waiting for your feedback.

PS: about the calibration procedure I was looking for, I can see in the data sheet that "the sensor is factory calibrated" and does need to be calibrated. While there is also a "1-point or 3-point tumble sensor calibration"... This information about the sensor needs to be clarified.

@MdeLv
Copy link
Author

MdeLv commented Mar 20, 2023

Two changes done.
Now "magnetic field" measures in uT are more realistic with known local mag field.

But :

1/ measures are still inaccurate ( ex: up to 70 uT for vertical mag field when 40 uT expected)
I can see only the solution of "1-point or 3-point tumble sensor calibration".
-> What is your experience with that calibration procedure?
Can we gain accuracy to reach 40 +/-5%? Or is this magnetometer a toy?

2/ measures are moving within a +/-1 uT range while sensor is not moving and mag field is not varying .
Using a rolling average on 2-3 s may stabilize the value displayed at the price of less reactivity when moving quickly.

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

No branches or pull requests

1 participant