Adafruit_Learning_System_Guides icon indicating copy to clipboard operation
Adafruit_Learning_System_Guides copied to clipboard

feather_sense_sensor_demo.ino (using Adafruit_LIS3MDL.h)

Open MdeLv opened this issue 1 year ago • 1 comments

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 avatar Mar 20 '23 02:03 MdeLv