Send commands from UART to RS232 using Arduino shield?

Hello,

Sorry to hijack this thread, but I’m working on exactly the same type of project with the same shield at the moment, and have a slightly different issue.

To allow simultaneous communication between RS232 and USB, could you bend pins 0 & 1 (TX & RX) on the shield out, so they don’t go into the Arduino, and run a connector between them and different pin headers (eg. to 10 and 11 and use SoftwareSerial to assign pins 10&11 as other serial pins)?

I did exactly this but received no data from the shield, but I can’t understand why. An oscilloscope showed the incoming data was fine, the RS232 from scales was +/-7V, with the expected waveform. On one of the shield pins 0 or 1 (that I’d bent out) I was expecting to see the same waveform, shifted to 0-5V, one was however outputting a constant 5V, and the other 2.5V. I confirmed I hadn’t introduced any shorts in the circuit. I also checked the RS232 headers- with the Arduino disconnected from power the waveform and voltage range matched the input quite well (despite some rounding of the wave), with the power connected the TX and RX headers went up to 5V, occasionally superimposed with the signal. Do I have a faulty shield?

Thanks

Yup, that would probably work. Actually, I recommended doing this in a tutorial a while back.

This seems like it would require more testing. You mention having a signal without the Arduino involved, so it seems like it would be possible the Arduino is causing the issue (or whatever else may be connected). I’d recommend posting pictures of your full setup.

That may be possible. If you think so after more testing, we recommend that you open a support ticket here.

Thanks for the suggestions and all the feedback. For this application I don’t need the USB connection except for de-bugging, I got confused by the SoftwareSerial documentation.

Essentially all I’m trying to do is send the ASCII characters “CP” to the scale on startup to trigger a response, and then listen to the RS232 lines and spit that data out on the serial monitor.

I’ve tried adapting the example code from the tutorial linked above to do just this basic task but I’m not receiving an output on the serial monitor. Is it possible to tell if there’s data coming over the RS232 lines without probing with an oscilloscope? And have I setup the example code properly?

One confusion I have is the relationship between the serial monitor and the serial lines. For example, I’m using Serial.print() to send a message to the scale and trigger it’s output. But I’m also using that command later to display the incoming messages on the serial monitor. Is there an article that disambiguates the serial monitor from the serial lines?

Thanks!

Hey,

Yeah, I get the confusion. This information is not clearly presented (to beginners, at least) for the Arduino. Maybe they kinda just assume everyone will just figure it out through community support?

Here’s the details:
The Arduino Uno has only one hardware UART peripheral, or commonly referred to as a “hardware serial port” or just “serial port” for short.

As you can see in the Arduino Uno R3 schematic (bottom), the Arduino pins 0/1 are connected to the hardware serial port of the AVR chip (ATmega328) and the USB interface. See the annotated image below for details:

Therefore, if your shield is hardwired to pins 0/1 (the hardware serial port), then sending commands to the shield (and through the RS-232 interface) or the USB interface also sends it to the other!

In Arduino terms, the Serial object is akin to Serial0, or the hardware serial port tied to the USB interface. In the case of the Arduino Uno, that also happens to be its only hardware serial port available.
On a Arduino Mega 2560, for example, you also have available Serial1, Serial2 and Serial3 that are also hardware serial ports.

The typical solution to this issue for Arduino Uno and other hardware limited microcontroller boards is to use what is referred to as a “software serial port”. What this means is to use software to control two GPIO pins to simulate the TX/RX lines. Therefore, this “virtual” serial port can be used pretty much any digital pins that are available on the microcontroller. The default example for SoftwareSerial uses pins 10/11.

In the case of this specific shield (unlike many others), you are forced to use the hardware serial pins and therefore cannot use a software serial port with it without changing the shield / rewiring where its RX/TX goes.

This is why we recommended the alternative of RB-Cyt-190 which allows you to connect the RX/TX lines to any pins of your choice since it is not a shield. It should be noted that some shields also have jumpers that allow you to choose different pins, such as 0/1 or 8/9, etc. These tend to cost a bit more, though (but not always).

Also please note when wiring two serial devices together (ex: an Arduino and a RS-232 to UART converter) that the TX of one device must be wired to the RX of the other and vice-versa for the other pair of input/output. Do not wire TX to TX or RX to RX! :slight_smile: Sounds simple, but it happens more often than you think… :smiley:

We hope this info helps!

One more thing to note. The serial monitor gets/sends information through the USB connection connected to the hardware serial port that was shown connected permanently to the USB port. It isn’t really practical to use the port for two different things at the same time (communicate with the shield and serial monitor)

Good point to reinforce. I thought I had covered it properly… but yeah, it wasn’t all that clear in my post! Thanks! :slight_smile:

This can be done, but it certainly requires quite a bit of thought about the process, the protocols involved, etc. Not trivial and certainly not for beginners! :slight_smile:
Keep it simple and only use each serial port for one thing at a time! :smiley:

Hi,
I’ve currently been working on a similar project. I’m attempting to interface an Ohaus Scout Pro Scale with an Arduino Atmega 2560, with little success so far. The scale has a default setting of 2400 7-N-1 and I initialized it as Serial2.begin(2400,SERIAL_7N1) the Serial2.available() never seems to trigger when hooked up to the scale. However, when I remove the Tx & Rx pins from the RS232-TTL converter the Arduino immediately attempts to transfer data across the serial port.
Any comments or suggestions would be appreciated.
Thanks,
Chris

It would be very helpful if you provided links to the items concerned and their documtation.

My apologies. I can’t upload the manuals for the Scale and the RS232 Interface because I’m new but they can be found at the following links:

The Rs232-TTL converter doesn’t have a datasheet but here is the amazon link:

I don’t have any experience with that scale or that particular RS232 converter. But here are a couple of things that come to mind.
First, you may have the TX and RX pins swapped from the Arduino to the converter. Often they are mislabeled. I would try that first.
Second, the TX and RX pins on the RS232 converter may be backward from what is needed to interface to the scale. Since the two pieces of equipment must be opposite and the converter AND the scale are probably both intended to plug into a PC, they are likely wired the same instead of opposite. That would mean the handshake lines are wrong, too.
Third, the handshake lines RTS and CTS may need to be used to communicate with the scale. I didn’t look that far into the manual. That’s a simple fix: connect them together.
I can think of some other possibilities but those are the three most likely. Of the three my first bet would be #2. The two types of connection are DTE and DCE. I forget which is wired which way and the names don’t really matter.
Here is a link to the computer pinout: http://www.usconverters.com/index.php?main_page=page&id=61&chapter=0
I suggest comparing those and checking all the connections.