RS232 comunication problem

Hi,

I have a problem with Serial comunication.

My components:
Arduino Mega
External device Serial config: 9600,8,1,0,0
each 10 sec send *XD,1234,1234,12,1234,1234,1234#
Device is grounded with arduino.

Similar result with any Serial port (1-3), i try SoftwareSerial too.

I expect some like this:
*XD,1234,1234,12,1234,1234,1234#

(char)Serial.read() I read some like this:

µęť•źŹk§ź—§źťŤ‘§źťźź§ź•źź§ź—•ź§ź›•Źą

Serial.read() I read some like this:

181 234 157 149 159 143 107 167 159 149 167 159 155 149 147 167 159 151 159 159 167 159 159 159 159 167 159 153 157 141 167 159 155 151 151 185

I use default SerialEvent sketch:

String inputString = ""; // a string to hold incoming data
boolean stringComplete = false; // whether the string is complete

void setup() {
Serial.begin(9600);
Serial1.begin(9600);
inputString.reserve(200);
}

void loop() {
if (stringComplete) {
Serial.println(inputString);
inputString = "";
stringComplete = false;
}
}

void serialEvent1() {
while (Serial1.available()) {
char inChar = (char)Serial1.read();
//delay(1); //no effect
//delay(10); //no effect
inputString += inChar;
Serial.print(inCahr);
//Serial.write(inCahr); //no effect
if (inChar == '\n') {
stringComplete = true;
}
}
}

Any Idea or solution?

THX

(deleted)

no converter - directly TX to RX

Directly to PC? It is wrong. You have to use level converter RS232/TTL based on chip like MAX232.
TTL is 0-5V and RS232 has +3v - +15V for 0 and -3V - -15V for 1.

Device connected to the PC via Serial/USB Profilic reduction working well.
I need to connect this device to the Arduino Mega.
Need I MAX32 converter?

USB/serial (on the Adrduino) has TTL on the serial side so it should work. If you want to connect RS232 on the PC or on the "Device" with serial on the Arduino, you need RS232/serial converter.
You have probably connected your "Device" with the USB/RS232 serial cable to PC but it has RS232 levels. It has not TTL so you will need RS232/TTL converter for Arduino. Something like this:

well thx i try it.

Perfect - working - one Max3232 any you safe me :slight_smile: THX

Good news. :slight_smile: