Firmware for ESP32 that reads BNO055 orientation (roll, pitch, yaw) and ThinPot analog depth, applies motion-aware filtering (median for spikes, raw while moving, heavy Kalman + EMA + SMA when stationary), and streams telemetry over BLE for VisionOS/VR clients.
- Sensors: Adafruit BNO055 + ThinPot.
- Adaptive filtering:
- Median filter (window=5) to de-spike input.
- Motion detection via recent variation.
- While moving → raw values for responsiveness.
- When stationary → Kalman + exponential smoothing (α=0.02) + 10-sample moving average.
- Auto-reset of filter state at motion→stationary transition to prevent lag.
- BLE telemetry: NimBLE-based server with notifications at 10 Hz (
delay(100)
).
- Service UUID:
"180C"
- Characteristic UUID:
"2A56"
(notify + read) - Payload (CSV):
roll_deg,pitch_deg,yaw_deg,depth_mm
Example:12.34,-1.02,178.90,57.3
- Board: ESP32 Nano
- Baud: 115200
- Libraries:
Adafruit_BNO055
Adafruit Unified Sensor
NimBLE-Arduino
- Notes:
bno.setExtCrystalUse(true)
enabled.
On boot, you’ll see a prompt; place the sensor in the desired starting orientation. After ~3 s, the code captures zero offsets (setZero()
).
Key parameters near the top of the sketch:
MOTION_THRESHOLD
(mm),MOTION_SAMPLES
MEDIAN_WINDOW
- Stationary filter:
Q
,R
,alpha
, andSTATIONARY_THRESHOLD
- BNO055: SDA → ESP32 SDA, SCL → ESP32 SCL, 3V3, GND
- ThinPot: Wiper →
THINPOT_PIN
(ADC), ends to 3V3 and GND
~10 Hz notifications (adjust delay(100)
).
- VisionOS / VR dashboards
- Haptics/robot control panels that need stable depth at rest and low-latency motion updates