I'm building my application with a ADXL 345 + ESP32 module using I2C communication, the library that I'm using is Adafruit_ADXL345_U.h. However change it if necessary.
My clock speed is now is 4MHz. I can change the sample rate easily using the functions created by Adafruit, however my acquisition is made in a 'for' loop. Where basically I keep reading the register of the axis that I would like to check. I can share the library and the code if is necessary. But my point is if my loop goes faster than the sample rate frequency I ll get more points than the adxl really provide, I think thats why I'm having some duplicate values. So when I 'measure' my sample rating dividing the number of samples/time of collection I got more than 3200 Hz, and I think that is not possible.
My objective is check if there is any new value and then try to read the register. Is there any flag in any register that can help me? I have tried to use DATA_READY but I think is just in the interruptions cases that it can be applied.
"DATA_READY The DATA_READY bit is set when new data is available and is cleared when no new data is available. " (adxl 345) datasheet
I ll be really glad if anyone can help me in this case.
My clock speed is now is 400KHz *** Correction!
I found this:
Due to communication speed limitations, the maximum output data rate when using 400 kHz I2C is 800 Hz and scales linearly with a change in the I2C communication speed.
Therefore I reduced to 800 Hz my acquisition. However when I check the the data I still have several triplicate values. I still need to check if there is new value to get before take a value.