Hospital Bed Angle Monitor
An IMU-based bed inclination monitor for head-of-bed elevation — the 30° threshold used clinically in ventilator-associated pneumonia prevention. Firmware streams orientation over both USB and Bluetooth into a browser client with a live 3D model.
Key Features
LSM6DS3TR-C IMU fused with a Madgwick AHRS filter for absolute pitch, roll and yaw at 25 Hz
Identical JSON streamed over both USB and BLE via the Nordic UART Service
Browser client on the Web Serial and Web Bluetooth APIs with a live three.js 3D model
Persisted calibration offset so the sensor can be mounted at any angle and zeroed in place
Diagnosed and fixed BLE line truncation caused by the default 23-byte ATT MTU
The Challenge
The board connected and streamed bytes, but the browser reported no valid readings. The cause was the default 23-byte ATT MTU on the BLE link: each JSON line was being truncated before its newline arrived, so the parser never saw a complete record. Raising the peripheral bandwidth and reframing writes at the transport layer fixed it. Yaw still drifts slowly — there is no magnetometer on this board — so pitch and roll, which gravity anchors, are the trustworthy numbers for a bed-incline reading.