Hi,currently testing a setup which involves a nano and a mega. Im doing this to test the functionality of RS232 modules which i need for another project(Did not work). So now im trying to debug by trying to communicate with a nano to see how the rs232 module works, however, I am getting no response.
A standard RS-232 cable should have a ground wire, so that should ties the grounds together.
Since you are using the hardware serial port on the Mega, you can do a loopback test with the RS-232 module by connecting pins 2 & 3 together on the RS-232 side. This will not work with SoftwareSerial.
I would print the characters as they are received, instead of waiting for the return character.
ive connect the respective rs232 to the 5v and GND of its arduino. however, i dont have the arduinos connected directly to the same ground of thats what the issue is?
I've tested your code.
I didn't have an Arduino Nano available, so I used an Arduino Uno R3 instead.
I found the code for the Mega wouldn't compile, I got the error message: 'inputBuffer' was not declared in this scope
So I added the line: String inputBuffer = ""; borrowed from the Nano code.
On the Nano code, I simply changed the pin numbers to reflect the pins that I was using for SoftwareSerial.
(My RS232 to UART converter was already soldered on to a prototype shield, so I have to use pins 4 and 5.)
Use the following hardware setup (Fig-1) to test the functionality of your RS232 Module. After that test it using Arduino-1, RS232-1, RS232-2, Arduino-2 setup.
Ah! @GolamMostafa - your drawing refreshed one of my last brain cells.
The issue might be with the DB9-DB9 cable... if it is "straight through" (pin 2 to pin 2), as most cables are, then no comms will occur between the modules. It must be "nulled" (pin 2 to pin 3, pin 3 to pin 2).