0
\$\begingroup\$

I am trying to communicate with an RFID reader via its serial port. The serial port has an RS232 connector on it. I also want to display the RFID tags ID on a 16x2 LCD screen using an Arduino.

I, therefore, purchased an RS-232 to TTL converter (shown below). enter image description here

I connected an RS-232 cable from the reader to the converter (male to male RS-232 cable) and then to my Arduino Nano. I connected TX (RS-232 converter) to RX (Arduino) and RX (RS-232 converter) to TX (Arduino).

After uploaded a simply sketch:

#include <SoftwareSerial.h>

SoftwareSerial mySerial(5, 6); // RX, TX

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

 // set the data rate for the SoftwareSerial port
 mySerial.begin(115200);
}

void loop() { // run over and over
 if (mySerial.available()) {
 Serial.write(mySerial.read());
 }
 if (Serial.available()) {
 mySerial.write(Serial.read());
 }
}

The code is not mine, it is an example sketch from Arduino. I set the baud rate as per the RFID reader's settings, which was 115200.

After connecting everything, I then opened up the serial monitor and set the correct baud rate. However, no info was sent to the monitor. I also got a Serial to the USB connector. I connected this cable to the reader and then to my PC USB input (no Arduino). I tested the serial connection with this cable and opened up the serial monitor, set the COM port and baud rate. The serial monitor started to display the correct data.

After investigating the RS-232 cable (male to male RS-232 cable) I noticed the DCD (Data Carrier Detect) and the RX pin of the RS-232 was shorted (I tested with the continuity tester from my multimeter). Could this be the reason why no data is been displayed?

Update:

enter image description here

enter image description here

enter image description here

\$\endgroup\$
3
  • 2
    \$\begingroup\$ I suspect either RX/TX are reversed (some devices "helpfully" reverse this so that RX connects to RX), or you need a NULL modem cable/adapter. \$\endgroup\$ – mbedded Aug 20 '20 at 22:19
  • \$\begingroup\$ Where's the datasheet link for the converter? See What to check for when buying an electronic component or module? electronics.stackexchange.com/a/504046/73158 \$\endgroup\$ – Transistor Aug 20 '20 at 22:29
  • \$\begingroup\$ @Transistor it as been added \$\endgroup\$ – Joey Aug 20 '20 at 22:34
2
\$\begingroup\$

Most likely there are multiple points of failure here.

First of all, the RS232 to TTL converter TX pin is an input for the RS232 transmitter, so the TX input must be connected to TX output pin of the Arduino. Likewise, the converter RX pin is an output from the RS232 receiver so it must be connected to Arduino RX input pin.

The RS232 to TTL converter DE-9 connector is a female like any other DCE, so the pin 2 is RS232 TX output, and pin 3 is RS232 RX input, and it is meant to be directly connected with straight through cable to a DTE like a PC. So when a DCE is connected to another DCE like the reader, it means that a crossover null-modem cable is needed, to connect TXD of one device to RXD of another device. Simply an adapter will have direct connection and will not work.

Then the final issue is that the Arduino is running at a 16 MHz clock. Also, the clock does not come from a crystal, but a less precise ceramic resonator, which is only accurate to about 0.5% initially and can deviate with temperature to about 1%.

Now, I don't know the details how the softwareserial works, but depending on what other things the program does, it may have problems running at 115200 rate reliably. Even using the hardware UART will not help much, as 16 MHz clock just does not allow for 115200 baud rate below 2% of error in the rate, and adding the ceramic resonator error, it may just result in so large error that it does not work at 115200. Suggested maximum error rate is within 2%.

\$\endgroup\$
3
  • \$\begingroup\$ I swapped the TX and RX to check if that was the issue and still did not solve my problem. But the latter part of your solution seems to explain why it will not display on the serial monitor. What other ways can I solve this issue? (Thanks for finally providing an answer!) \$\endgroup\$ – Joey Aug 21 '20 at 21:25
  • 1
    \$\begingroup\$ Just buy a null-modem cable and use lower baud rate. Or use something that can support 115200 reliably instead of Arduino softwareserial. \$\endgroup\$ – Justme Aug 21 '20 at 21:27
  • \$\begingroup\$ Thank you the baud rate cannot change, so will just use a Rasberry Pi instead. \$\endgroup\$ – Joey Aug 21 '20 at 21:33
0
\$\begingroup\$

RXD on the converter header connects to pin R1OUT on its MAX3232; it's an output, and should be connected to the RX input of the Arduino. Likewise, the TXD pin should be connected to the TX output of the Arduino.

Both RS232 ports may also be DCE wired, so you may also need a Null Modem cable/adapter to connect the two.

\$\endgroup\$
1
  • \$\begingroup\$ Removed the cable and added a null modem straight to the converter TTL. swapped the wires and still no data \$\endgroup\$ – Joey Aug 20 '20 at 23:18
0
\$\begingroup\$

Try one of the following:

Make sure that Arduino and the converter are sharing the same GND.

Make sure that you have chosen the correct COM port.

Make sure that you have chosen the correct board in the sketch setup.

Make Sure that the programmer is adequate for your board " Usually its (ArduinoISP) "

\$\endgroup\$
0
\$\begingroup\$

You are asking a software serial port to run at 115200 baud. I think that is far too fast for a software serial port to work reliably. Try it at 9600 baud just to check the wiring.

\$\endgroup\$
1
  • \$\begingroup\$ But I cannot change the baud rate of the RFID reader, so if even it works at 9600, it will be pointless because the RFID reader runs at 115200. \$\endgroup\$ – Joey Aug 21 '20 at 21:18

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.