21 0 4 14 255 232 0
22 8 0 72 255 252 255
23 228 255 232 255 252 0
24 32 0 8 255 200 255
25 224 0 32 0 12 255
26 212 255 244 255 252 255
27 248 0 16 0 0 255
28 240 0 44 0 12 0
29 16 255 200 255 220 0
30 8 0 44 255 220 255
31 248 0 16 255 228 0
If I then convert this to g values for X ,Y, and Z, I see the following for that same data:
0 -0.00, 0.00, -0.01
1 0.00, 0.00, -0.01
2 -0.00, -0.00, -0.01
3 -0.00, -0.00, -0.00
4 0.00, -0.00, 0.00
5 -0.00, -0.00, -0.00
6 -0.00, -0.00, 0.00
7 -0.00, 0.00, 0.00
8 0.00, 0.00, -0.00
9 -0.00, -0.00, 0.00
10 0.00, 0.00, -0.00
11 0.00, -0.00, 0.01
12 -0.00, -0.00, -0.00
13 -0.00, 0.00, -0.00
14 0.00, 0.00, -0.00
15 -0.00, -0.00, -0.01
16 -0.00, -0.00, 0.00
17 0.00, 0.00, 0.00
18 0.00, 0.00, -0.00
19 0.00, -0.00, 0.00
20 -0.00, 0.00, -0.01
21 0.00, 0.47, -0.75
22 0.25, 2.28, -0.09
23 -0.84, -0.72, -0.12
24 1.00, 0.28, -1.72
25 -1.00, 1.00, 0.41
26 -1.34, -0.34, -0.09
27 -0.25, 0.50, 0.03
28 -0.50, 1.38, 0.38
29 0.53, -1.72, -1.12
30 0.25, 1.41, -1.09
31 -0.25, 0.53, -0.88
Now here, we see zero g on all three axes (whereas we should see ~1g on the z-axis) until we get to the 21st event and then the data goes all over the place.
I can only conclude that the method I am using to read the FIFO is incorrect. Can anyone see the error in my method and share some pointers with me?
Thank you!
What I found was that the break in the data occurred in the 22nd group of data (row number 21, base 0). Each group is 6 bytes. 6 * 21 =126... the glitch was happening at byte 128... The I2C buffer length on the ESP32 in the Wire.h library is set at 128. There are multiple non-elegant solutions, such as editing the Wire.h (which is not acceptable since an update to Wire.h would overwrite the edits). But the Espressif folks pointed out that a complier option would do the trick... so in my platformio.ini file, under build_flags =, I added
-DI2C_BUFFER_LENGTH=255
That's a bigger buffer than I actually need, but it does the trick.
Hi,
It is hard to say where the problem might be without seeing your source code or accelerometer configuration.
I would recommend you to take a look at my example code that illustrates how use of the embedded FIFO buffer to collect the 14-bit acceleration data that are read from the FIFO using an interrupt technique.
Some more details on the configurations of the FIFO buffer as well as more specific examples can be found in the AN4073.
BRs, Tomas