SEN-17589 - KX13X accelerometer, trouble with dataReady() in example1_basic_readings

Hey there,

I’ve run into a blocker that has me spinning my wheels. Specifically, in the Sparkfun KX13X Arduino Library https://github.com/sparkfun/SparkFun_KX … no_Library, in example1_basic-readings, the check for dataReady() always returns false. This is the case even though the accelerometer does actually return plausible data when I comment out the check for dataReady.

The relevant code is

ln 63 kxAccel.enableDataEngine(); // Enables the bit that indicates data is ready.

and

ln 73 if( kxAccel.dataReady() )

Am I making a bone-head mistake? I’m using the KX134 version of the board and running the example on a PJRC Teensy 4.1.

Many thanks in advance,

Andrew

P.S. Having been in touch with @El Duderino, I understand that the KX13X library was recently updated (October 2022), and that the tutorials on the Sparkfun site still refer to a previous version. It occurs to me that errors may also been introduced in the example sketches in the library. In fact, I suspect there may be an unrelated error in example4_tap.

Did you comment out the kx132 line and uncomment the kx134 line @ ~26-27? Does the python code work for you?

Many thanks for the reply, @TS-Russell.

A definite yes to commenting out the KX132 line and uncommenting the KX134.

With the call to dataReady commented out, the example code does return data from the accelerometer. Plus, I haven’t yet run into an occurrence of the device not initializing properly. That was over a few dozen or more tries. That said, I’d be happier knowing why the check for data always fails.

I have zero experience with Python. If that seems to be the best way forward, I’ll check it out.

Still, I am curious to know if anyone has succeeded with example1 from the latest version of the Arduino Library as written. The other example I tried, example4, also gave me some trouble. I suspect a typo on line 85 where the delay is set to 25ms. When set to 2.5 (i.e. 1000/400), it worked. This is completely unrelated to the dataReady business, of course.

Best,

Andrew

I just had issues with the arduino examples 1&4 as well; file an ‘issue’ here https://github.com/sparkfun/SparkFun_KX … ary/issues

Super. Thank you for confirming. Much appreciated.

I’ll open a ticket as you suggested.

Thanks @Landru for the issue in the github repository. The short of the problem was that the IC needed proper time to reset. This issue was exposed with the Teensy because it’s such a fast processor, but not with the particular one that I developed the library with. As for example four - I did bad math and put in the wrong delay time. Everything should be good with the library now.