diff --git a/firmware/xiao-esp32c6-sensor-node/README.md b/firmware/xiao-esp32c6-sensor-node/README.md index 36f5419..09b2a67 100644 --- a/firmware/xiao-esp32c6-sensor-node/README.md +++ b/firmware/xiao-esp32c6-sensor-node/README.md @@ -14,3 +14,5 @@ Power both sensors from 3.3V with shared ground. Required Arduino libraries are At startup the firmware scans D7/D8 and accepts either valid BNO08x address, `0x4A` or `0x4B`. If neither appears in the scan, verify 3.3V/GND, swap-check SDA and SCL, and confirm the breakout's PS0/PS1 jumpers are configured for I2C. The node sends `sensor_status` at 115200 baud every 200 ms. See `docs/SENSOR_NODE_PROTOCOL.md`. The initial firmware is transmit-only; 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. diff --git a/firmware/xiao-esp32c6-sensor-node/rs485_transport.cpp b/firmware/xiao-esp32c6-sensor-node/rs485_transport.cpp index a13b223..3d5c4bb 100644 --- a/firmware/xiao-esp32c6-sensor-node/rs485_transport.cpp +++ b/firmware/xiao-esp32c6-sensor-node/rs485_transport.cpp @@ -26,5 +26,9 @@ void publishSensorStatus(HardwareSerial& serial, const ImuState& imu, const GpsS digitalWrite(RS485_DE_PIN, HIGH); delayMicroseconds(20); serializeJson(doc, serial); serial.write('\n'); serial.flush(); digitalWrite(RS485_DE_PIN, LOW); -} +#if USB_TELEMETRY_ENABLED + serializeJson(doc, Serial); + Serial.println(); +#endif +} diff --git a/firmware/xiao-esp32c6-sensor-node/sensor_node_config.h b/firmware/xiao-esp32c6-sensor-node/sensor_node_config.h index b95ac61..ecd5dfa 100644 --- a/firmware/xiao-esp32c6-sensor-node/sensor_node_config.h +++ b/firmware/xiao-esp32c6-sensor-node/sensor_node_config.h @@ -19,3 +19,4 @@ #define IMU_REPORT_INTERVAL_US 20000 #define TELEMETRY_INTERVAL_MS 200 #define SENSOR_STALE_MS 2000 +#define USB_TELEMETRY_ENABLED 1 diff --git a/tests/test_xiao_sensor_node_contract.py b/tests/test_xiao_sensor_node_contract.py index e0139d0..a56867c 100644 --- a/tests/test_xiao_sensor_node_contract.py +++ b/tests/test_xiao_sensor_node_contract.py @@ -15,6 +15,8 @@ def test_transport_contract(): text = source("rs485_transport.cpp") for token in ['doc["type"] = "sensor_status"', 'doc["schema_version"]', 'createNestedObject("imu")', 'createNestedObject("gps")', "serial.write('\\n')", "serial.flush()"]: assert token in text + assert "USB_TELEMETRY_ENABLED" in text + assert "serializeJson(doc, Serial)" in text def test_loop_is_non_blocking(): loop = source("xiao-esp32c6-sensor-node.ino").split("void loop()", 1)[1]