1

I am trying to read data from an RS232 equipped sensor using a serial monitor connected to an Arduino Mega with RS-232 shield but I do not receive any data.

I am unable to detect the exact cause of the problem, as it only occurs when combining sensor and RS232shield/Arduino, while communication works as expected when testing them separately

What works:

  • Connecting the sensor to a computer with a RS232-USB converter cable.
  • Passing data from the computer through the USB-RS232 converter cable to RS232 shield and back through Arduino USB output.
  • Connecting the RS232-pin 2 to port 10 using {SoftwareSerial} library with inverted logic.

What does not work:

  • Passing data from the sensor to the computer via the MAX232 and Arduino.

The setup:

  • Arduino Mega 2560
  • Seeed RS232 shield (MAX232 based)
  • Sensor with RS232 output (57600 8N1)

I have connected the RS232 output of the sensor to the shield using an M-M gender changer. The shield and Arduino are connected with three wires: GND-GND , 5V-5V, 232_TX-RX1), and the Arduino connects to a Macbook via USB. The serial monitor on the computer is set to 56700 baud.

I use the following sketch to transfer data from the RS232 shield to Serial:

void setup()
{
// Open serial communications at 5700 baud
 Serial.begin(57600);
 Serial1.begin(57600);
// Check whether Serial1 is active
if (Serial1.available())
 while (!Serial1) {
 ;
 }
 Serial.println("Serial 1 is active");
}
void loop()
{
 if (Serial1.available()){
 Serial.write(Serial1.read());
 }
}
asked Dec 2, 2019 at 11:00
1
  • Does your sensor require hardware flow control signals that the shield doesn't provide? Commented Dec 2, 2019 at 11:50

1 Answer 1

2

I have solved the above and will share the answer as it may be of help to others:

As the Tx indicator LED on the RS232 shield would not light up when connected to the sensor, I checked the voltage difference between pin 2 (Tx) and pin 5 (GND) of the RS232 connector. This turned out to be only 5V, indicating that the protocol used is TTL-RS232 rather than 'true' RS232.

Due to the low voltage, I have connected the RS232 Tx and GND pins directly to the Arduino. With Tx connected to digital port 10, I used the SoftwareSerial library with logic inversion to read the data: SoftwareSerial mySerial(10, 11, 1).

This works!

answered Dec 2, 2019 at 12:11
1
  • this is not an answer to the question, because the answer uses information not mentioned in the question. what sensor is it? Commented Dec 2, 2019 at 14:25

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.