Unable to send proper data via RS232

I have a device that accepts RS232 connection. It's used with QR code readers such as "Access IS".
This scanner has begin and end values and set to 02 for begin, 03 for end. If I scanned using the barcode the letter "a", the device debug successfully prints:

  • 2022.02.02T18:27:21.426; DEBUG; RS232; RX; 026103;
  • 2022.02.02T18:27:21.433; INFO; EVENT; IO.BarcodeRead; a;

Now I want to mimic the same behavior and send similar data to the device but using the a chip such as the ESP32. I used this code:

void setup()
{
  Serial.begin(19200);
}

void loop() // run over and over
{
  delay(2000);
  byte message[] = {0x02, 0x61, 0x03 };
  Serial.write(message, sizeof(message));
}

But the device is receiving this instead:

  • 2022.02.03T12:54:40.195; DEBUG; RS232; RX; bf;
  • 2022.02.03T12:54:40.202; DEBUG; RS232; RX; 4f7e00;

I'm new to this and I really appreciate all the help I can get to find a solution.

The ESP32 does not output RS232 level signals so what sort of signal converter do you have between it and the RS232 device, if any ?

I've used the onboard TX with GND only. Connected to device RX and GND.
I have tried with Arduino 33 BLE and I'm getting the same results.

Read reply #2.
You need a converting curcuit. RS332 works with +- 12 volt levels. You only have 0 and 5, maybe only 3.3 volt signals from the controller.

Thanks, I will look into this to get the converter. I thought maybe it's something related to my code but I wanted to make sure. I wish there is a way to test this before getting the converter.

No, You need a TTL to RS232 converter. It has ben used for 30 - 40 years. There's no use for any testing before.

I'll be getting one and test with it then update you all. Many thanks!