ldab / KXTJ3-1057

KXTJ3-1057 Tri-axis Digital Accelerometer - Arduino Library
MIT License
14 stars 8 forks source link

16g doesn't work? #14

Closed gotfredsen closed 1 year ago

gotfredsen commented 1 year ago

When using 16g as accelRange, I get minimum 1.5g, when the sensor is just flat on the table, while 8g or lower "correctly" shows a magnitude of 1.1g.

I doesn't matter what I do with sampleRate or HIGH_RESOLUTION/LOW_POWER flags. Btw same problem in version 0.1

Am I doing something wrong?

ldab commented 1 year ago

I believe this was fixed/implemented on the latest PR, please check version 0.1.0

nomakewan commented 1 year ago

This was indeed corrected in #13 if you were using the axisAccel function to print your values. The reason was the 16g range was using a divisor of 1280 instead of 2048. This was likely done to try to correct for the junk data present in the unused lower bits when in 8-bit low power mode.

Likewise those HIGH_RESOLUTION/LOW_POWER flags never worked due to context switching (it was always running in low-power mode regardless of what setting you had), and have now been moved to the begin() function.

Please do give the new code a try (it should be pushed to the Arduino IDE's Library Manager in a few hours) and see if it works!

EDIT: I've confirmed 0.1.0 is now available through the Library Manager!

gotfredsen commented 1 year ago

Thank you. I tried the PR#13 yesterday, and it is perfect.