I’m using an Adafruit Huzzah ESP8266 board to talk to the oDrive UART. The oDrive is receiving and responding to commands - I’ve only tried setting position, but it works fine. I’m experiencing problems reading properties from oDrive - I’m getting ‘unknown command’ back when I send ‘r vbus_voltage\n’.
I’ve looked at the oDriveArduino source files and I’m implementing the comms directly without the library. Here’s the essence of the code:
Serial.begin(115200);
printf("r vbus_voltage\n");
delay(1000);
float volts = oDriveReadString().toFloat();
//volts is sent to a web socket so I can check it - it's always 0.00
String oDriveReadString() {
String str = "";
static const unsigned long timeout = 1000;
unsigned long timeout_start = millis();
for (;;) {
while (!Serial.available()) {
if (millis() - timeout_start >= timeout) {
return str;
}
}
char c = Serial.read();
if (c == '\n')
break;
str += c;
}
return str;
}
I gather from the forum that there shouldn’t be an issue with ESP8266 and oDrive logic levels - they are both 3.3 V.
Looking at ascii_protocol.cpp, the only way ‘unknown command’ can be returned is if the first character of the command isn’t recognised (e.g. cmd[0] != ‘r’). I don’t have a clue why my cmd[0] isn’t ‘r’ - I’m sending an ‘r’ as required, and the position command ‘p’ works fine.