sequenceDiagram participant HW as MPU6050 Hardware participant MPU as MPU Task
(Core 0) participant CH as IMU_CHANNEL
[16 slots] participant MAIN as Main Loop
(Core 0) participant LATEST as IMU_LATEST
(Mutex) participant MQTT as MQTT Task
(Core 1) participant DISP as Display API Note over MPU: Every 50ms MPU->>HW: Read sensor (I2C) HW-->>MPU: Raw data MPU->>MPU: Convert to ImuReading MPU->>CH: try_send(reading) alt Channel full CH--xMPU: Drop (log warning) else Channel has space CH-->>MPU: OK end Note over MAIN: Continuous loop MAIN->>CH: receive() [blocking] CH-->>MAIN: reading Note over MAIN: Drain queue loop While available MAIN->>CH: try_receive() CH-->>MAIN: newer reading end MAIN->>DISP: show_imu(reading)
[try_send] Note over MAIN: Every 3 seconds alt Time >= 3s since last MAIN->>MAIN: Format JSON payload MAIN->>LATEST: mqtt_set_imu()
[try_lock] alt Mutex available LATEST-->>MAIN: Stored else Mutex locked LATEST--xMAIN: Skip end end Note over MQTT: Continuous loop MQTT->>LATEST: try_lock() alt Data available LATEST-->>MQTT: payload MQTT->>MQTT: send_message("esp32/imu") else No data LATEST--xMQTT: None end