Software Serial and HEX data

Hello guys,

I am using softwareserial command to extract data from a RS232 cable. I am sending a string 'hello' getting the data in HEX format. Can anyone suggest me to how to obtain data?

When in ASCII format I get the display as : ⸮⸮⸮R

#include <SoftwareSerial.h>

SoftwareSerial mySerial(10, 11); // RX, TX

void setup() {
// Open serial communications and wait for port to open:
Serial.begin(9600);
while (!Serial) {
; // wait for serial port to connect. Needed for native USB port only
}

mySerial.begin(9600);

}

void loop() { // run over and over

//mySerial.println ("working");
delay (1000);

if (mySerial.available()) {
Serial.print(mySerial.read(),HEX);
}
if (Serial.available()) {
mySerial.print(Serial.read(),HEX);
}

delay (500);
}

If you're using RS232, you need a level converter (e.g. MAX232).

RS232 uses different levels; -3..-15V (or even -24V) represent a logic 1, +3..+15V (or even +24V) represent a logic 0. See RS-232 - Wikipedia

Merry Christmas.

Is the problem in the receiving side due to the moderator? Or is there any coding error as well? Please clarify.

At present I have directly connected the pins of DB9 connector (2,3,9) to the TX,RX and ground with jumper wires.

I don't see a coding error.

You can't connect RS232 like that to an Arduino; you might be in the process of sending your Arduino to heaven.

You need something like https://www.botshop.co.za/product/max3232-rs232-to-ttl-converter-module/?gclid=EAIaIQobChMI5eusx7C63wIVhc13Ch1ifwMLEAYYASABEgLwOfD_BwE (just the first one that google returned)

Using a RS232 to ttl converter worked well for me. Thank you guys.