From 4e68dcef5f98869b7baefebb27a13845b62e3868 Mon Sep 17 00:00:00 2001 From: Mikkeli Matlock Date: Sun, 1 Feb 2026 12:09:11 +0900 Subject: [PATCH] arduino: working altsoftserial with WT61 IMU --- arduino/.gitignore | 3 +++ arduino/main/imu.cpp | 10 +++------- arduino/main/main.ino | 9 ++++++++- 3 files changed, 14 insertions(+), 8 deletions(-) create mode 100644 arduino/.gitignore diff --git a/arduino/.gitignore b/arduino/.gitignore new file mode 100644 index 0000000..bc1f08c --- /dev/null +++ b/arduino/.gitignore @@ -0,0 +1,3 @@ +# arduino test files + +test/ \ No newline at end of file diff --git a/arduino/main/imu.cpp b/arduino/main/imu.cpp index c73f2bf..60cebd1 100644 --- a/arduino/main/imu.cpp +++ b/arduino/main/imu.cpp @@ -83,15 +83,11 @@ void imu_init() { // Sets WT61 to 9600/20Hz - see IMU.md for command reference // Idempotent: if already at 9600, command is garbled and ignored imuSerial.begin(115200); - - /* uncomment after I wire up Nano D9 -> WT61 RX*/ - // imu_send_cmd(0x64); // 9600 baud / 20Hz - // delay(100); // Let WT61 process and restart + imu_send_cmd(0x64); // 9600 baud / 20Hz + delay(100); // Let WT61 process and restart // Switch to working baud rate - // imuSerial.begin(9600); - /* uncomment after I wire up Nano D9 -> WT61 RX*/ - + imuSerial.begin(9600); rxIndex = 0; currentData = {0}; } diff --git a/arduino/main/main.ino b/arduino/main/main.ino index 880dcc3..1f15c98 100644 --- a/arduino/main/main.ino +++ b/arduino/main/main.ino @@ -12,17 +12,24 @@ static unsigned long lastTelemetryTime = 0; void setup() { pinMode(LED_BUILTIN, OUTPUT); + comms_init(); // Hardware Serial first so we can debug + Serial.println(F("[INIT] comms ok")); + voltage_init(); + Serial.println(F("[INIT] voltage ok")); + imu_init(); // AltSoftSerial on pins 8(RX)/9(TX) - comms_init(); // Hardware Serial to Pi at 115200 + Serial.println(F("[INIT] imu ok")); // Let IMU warm up a bit before calibrating // (WT61 needs a moment to stabilize after power-on) delay(500); + Serial.println(F("[INIT] calibrating...")); // Zero calibration - current position becomes reference // Blocks for ~250ms while sampling imu_calibrate(); + Serial.println(F("[INIT] calibration done, entering loop")); } void loop() {