Repository navigation
Description
When running the modified "Linear Accelerometer" example with the sensor stationary, it is possible to see the outliers in the acceleration on line 9:
- acx_unf:00.004, acy_unf:00.031, acz_unf:00.051, Roll:00.000, Pitch:00.000, Yaw:00.000, trust accel:3, Delta (μs):40.791
- acx_unf:00.043, acy_unf:00.008, acz_unf:00.012, Roll:00.000, Pitch:00.000, Yaw:00.000, trust accel:3, Delta (μs):40.801
- acx_unf:00.023, acy_unf:00.016, acz_unf:00.004, Roll:00.000, Pitch:00.000, Yaw:00.000, trust accel:3, Delta (μs):40.810
- acx_unf:00.004, acy_unf:00.012, acz_unf:00.012, Roll:00.000, Pitch:00.000, Yaw:00.000, trust accel:3, Delta (μs):40.825
- acx_unf:00.004, acy_unf:00.012, acz_unf:00.008, Roll:00.000, Pitch:00.000, Yaw:00.000, trust accel:3, Delta (μs):40.840
- acx_unf:00.012, acy_unf:00.020, acz_unf:00.008, Roll:00.000, Pitch:00.000, Yaw:00.000, trust accel:3, Delta (μs):40.855
- acx_unf:00.016, acy_unf:00.000, acz_unf:00.004, Roll:00.000, Pitch:00.000, Yaw:00.000, trust accel:3, Delta (μs):40.861
- acx_unf:00.016, acy_unf:00.008, acz_unf:00.043, Roll:00.000, Pitch:00.000, Yaw:00.000, trust accel:3, Delta (μs):40.876
- acx_unf:00.016, acy_unf:122.031, acz_unf:49.012, Roll:00.000, Pitch:00.000, Yaw:00.000, trust accel:3, Delta (μs):40.888
- acx_unf:00.004, acy_unf:00.008, acz_unf:00.004, Roll:00.000, Pitch:00.000, Yaw:00.000, trust accel:3, Delta (μs):40.897
- acx_unf:00.023, acy_unf:00.016, acz_unf:00.008, Roll:00.000, Pitch:00.000, Yaw:00.000, trust accel:3, Delta (μs):40.906
- acx_unf:00.016, acy_unf:00.008, acz_unf:00.008, Roll:00.000, Pitch:00.000, Yaw:00.000, trust accel:3, Delta (μs):40.927
- acx_unf:00.004, acy_unf:00.035, acz_unf:00.031, Roll:00.000, Pitch:00.000, Yaw:00.000, trust accel:3, Delta (μs):40.936
- acx_unf:00.023, acy_unf:00.000, acz_unf:00.004, Roll:00.000, Pitch:00.000, Yaw:00.000, trust accel:3, Delta (μs):40.957
- acx_unf:00.016, acy_unf:00.000, acz_unf:00.012, Roll:00.000, Pitch:00.000, Yaw:00.000, trust accel:3, Delta (μs):40.966
Description: With SH2_LINEAR_ACCELERATION and SH2_GAME_ROTATION_VECTOR enabled together (5 ms), SHTP packets are ~100 bytes and are read in ~4 chunks because _maxBufferSize = 32. Occasionally an accelerometer report has its Y/Z bytes replaced by the header of the following report. Example: acy = 122.031, acz = 49.012 while stationary, which is raw 08 7A 03 31 = [reportId 0x08][seq][status 0x03][delay]. Timestamps of those reports are also wrong (seq/delay reset, no 0xFB base timestamp report). Status stays at 3, so it can't be filtered by accuracy.
Observation: setting _maxBufferSize = 128 (ESP32's Wire buffer size) eliminated the problem, so the multi-chunk reassembly in i2chal_read() is the suspect. I haven't identified the exact mechanism.
Suggestion: default _maxBufferSize to I2C_BUFFER_LENGTH when the platform provides it, and review the chunk-continuation logic.
Environment: ESP32-S3, Arduino core X.Y.Z, 100 kHz, external 3.3k pull-ups.
Activity