2023-10-24 06:35 PM
Recently, I created a driver for the lis3mdl sensor. The sensor is providing data, but there are issues with the temperature readings and potentially with the magnetometer data. I don't have prior experience with magnetometers, so I'm uncertain if the data is accurate. When I move the sensor in different directions, the data changes, but I'm not sure if it should be close to zero. Additionally, there's a temperature discrepancy of about 10 degrees; the sensor shows 50 degrees in my apartment while my thermostat reads 72 degrees. Below, I've included images showing the initialization, output, and temperature/magnetometer data readings. It's worth noting that I divided the temperature data by 256 based on recommendations from this article https://forums.adafruit.com/viewtopic.php?p=900905 for improved accuracy.
2023-10-24 08:28 PM
The datasheet says 8 LSB per degree Celsius, so divide by 8, not 256.
Temp = 25 + counts / 8
Magnetometer readings will not be near zero. Those readings look fine. Converting readings to a NSEW direction is rather complicated, but involves finding the center of the readings you get when you rotate the sensor all around, and subtracting the mean.
2023-10-25 08:08 AM