XIAO ESP32-C6 Sensor Node
This Arduino sketch reads a BNO086 IMU and MAX-M10S GPS and publishes versioned, newline-delimited JSON over the Seeed RS485 expansion board. It produces vehicle telemetry only; Cargo remains the controller and /api/v1 authority.
| Function | XIAO pin |
|---|---|
| RS485 DE / RX / TX | D2 / D4 / D5 |
| BNO086 SDA / SCL | D7 / D8 |
| GPS TX to XIAO RX | D9 |
| GPS RX from XIAO TX | D10 |
Power both sensors from 3.3V with shared ground. Required Arduino libraries are Adafruit BNO08x, TinyGPSPlus, and ArduinoJson 6.x. Enable USB CDC On Boot for diagnostics. GPS uses hardware UART0 at the verified 38400 baud; RS485 uses hardware UART1.
The BNO086 uses the verified 0x4B I2C address on D7/D8. If initialization fails, verify 3.3V/GND, SDA/SCL wiring, and the breakout's PS0/PS1 configuration.
Firmware retries the fixed address during power-up and periodically retries afterward, so a slow BNO086 power-up does not require cycling the XIAO. If the BNO086 resets at runtime, rotation-vector reporting is enabled again automatically.
The node sends sensor_status at 115200 baud every 250 ms. See docs/SENSOR_NODE_PROTOCOL.md. It also listens between frames for the documented level-calibration commands. Add a dashboard receiver after bench-testing the node, RS485 polarity, and sensor axes.
During bring-up, USB_TELEMETRY_ENABLED mirrors each RS485 JSON frame to the Arduino Serial Monitor at 115200 baud. Set it to 0 in sensor_node_config.h when continuous USB output is no longer wanted.