I want to take the readings(output) from a Radar that has RS232 interface using an Olimex ESP32-POE. I am planning to use the UEXT connector of the ESP to connect to the RS232 interface.
The problem is that this is the first project in which I am trying to use the serial communication of the ESP and I have no idea what to write in code.
This is the only relevant piece of code I found:
Code: Select all
#define RXD2 16
#define TXD2 17
char c;
String readString;
void setup() {
// Note the format for setting a serial port is as follows: Serial2.begin(baud-rate, protocol, RX pin, TX pin);
Serial.begin(115200);
Serial2.begin(9600, SERIAL_8N1, RXD2, TXD2);
Serial2.println("serial2test");
Serial.println("Serial Txd is on pin: " + String(TX));
Serial.println("Serial Rxd is on pin: " + String(RX));
}
void loop() {
while (Serial2.available()) {
c = Serial2.read();
readString += c;
}
if (readString.length() > 0) {
Serial.print(readString);
Serial2.print(readString);
//server.print(readString);
readString = "";
}
}
Can somebody point me in the right way ? Thank you !