> the sensor has its own built-in sample rate, 400 times per second. If I read it too quickly, I might just be grabbing the same number twice
The author is configuring the sensor wrong i think. The usually way is you setup sampling rate of register, setup fifo inside register, wait for interrupt from sensor(through GPIO pin), then read from FIFO. Just blindly read data from sensor will get you in trouble, like reading duplicate value
Not all microcontrollers[1]} have FIFOs for stuff like this, but perhaps you meant implementing it in software as a regular queue or something.
Anyway, even easier since the OP seems to be dealing a lot with the time between samples, would be to just make sure that at least 2.5 ms have passed before reading the sensor again. Right?
[1] Not sure if older blog posts detail the hardware, I do remember reading about this product on here before.
No, i mean the FIFO inside the sensor. The sensor will populate FIFO itself, and trigger interrupt to MCU when the FIFO is full(or half full, configurable)
The author is configuring the sensor wrong i think. The usually way is you setup sampling rate of register, setup fifo inside register, wait for interrupt from sensor(through GPIO pin), then read from FIFO. Just blindly read data from sensor will get you in trouble, like reading duplicate value