Hi,
I have a serial device hooked up to my Arduino (ESP32 WROOM). I'm not a serial expert but I have at least some stuff working. The manual is chinese (or at least, very broken english) and I'm trying to make sense of it.
The device needs to be configured as such:
- Baud rate: 115200
- Word width: 8bit
- Stop bit: 1
- Parity: None
- Flow control: none (no idea what that is?)
- Receive/send settings: ASCII
I would assume that is done by doing: (it's on RX2/TX2)
MMWave.begin(115200, SERIAL_8N1, 16, 17);
When I try the following code I get the output from the device as expected:
#include <Arduino.h>
HardwareSerial MMWave(1);
const byte numChars = 32;
char receivedChars[numChars]; // an array to store the received data
bool newData = false;
void setup() {
Serial.begin(115200);
MMWave.begin(115200, SERIAL_8N1, 16, 17);
}
bool sent = false;
void loop() {
byte index = 0;
while(MMWave.available() > 0) {
char rc = MMWave.read();
receivedChars[index] = rc;
index++;
if (rc == '\n') {
Serial.print(receivedChars);
index = 0;
delay(1000);
}
}
}
The output is exactly as in the manual:
mov, dis=2.95
mov, dis=2.83
mov, dis=2.83
Now comes the problem, I can write parameters to the device as well. They say to send/receive data in ASCII in the manual and that when I write the command "get_all" to the device I should get a response returning all the current configuration parameters.
If I do not get the feedback from the device the manual tell me to make sure that the command is sent "with a carriage return and line feed".
I would expect that when I:
MMWave.write("get_all");
MMWave.write('\r');
MMWave.write('\n');
And then use the above code to read again...I would get the output from the command. But instead it keeps outputing the mov lines (default output) and it doesn't respond at all to my command. I also tried to:
MMWave.println("get_all");
And
MMWave.print("get_all\r\n");
Nothing seems to work. Any advice would be greatly appreciated. I have read alot of serial introduction stuff but I can't seem to match the correct info to my use case.
Thank you guys in advance!