I am planning to connect DI/O pins 0 and 1 (RX and TX pins) to a device that uses a RS-232 serial connection. I assume that RX on Arduino should be wired to TX on the device and vice versa, based off of some diagrams I have found. I also am aware that I will need to do something to make sure the Arduino isn't damaged because the device uses 12v and the board uses 5v. A level shifter would work to convert 12v to 5v.
However, to my understanding, wiring a circuit with just the level shifter will only work in one direction (RS-232 device to Arduino), and because I am sending data to the device from the Arduino, it won't be able to do what I need it to.
My questions:
-
What can I do be able to safely connect RX and TX to the RS-232? I found something called a boost converter to raise the Arduino's 5v to 12v for the device, but have not seen it mentioned in any forum posts on Arduino discussing using a boost converter in this situation. I have a feeling this may not be the right way to go from here.
-
I see that the DI/O pins use 20 mA and have heard a RS-232 connection ranges from 10 mA to 45 mA. What can I do to control the current if it is too high? I do not seem to be able to find answers to this question through an internet search, so even just some tips on what to search for on Google is appreciated.
-
For clarification: If I use pins 0 and 1, I have heard that you cannot keep the Arduino plugged in with USB at the same time, and anything connected to these will need to be unplugged while uploading a sketch. Is this correct?
-
Is what I am trying to do possible (sending serial data from Arduino with pins 0 and 1 to another device with an RS-232 port)?
Thank you,
Ao.
Notes: Sorry if my English is wrong, please ask if something is unclear and I will try to rephrase. I am not very informed about electrical topics yet, so I may have some misunderstandings about this, though I have attempted to clarify information for myself.
wildbill:
Do a search for MAX232.
Thank you, this answers most of my questions and is just what I'm looking for. I will order one and try it out.
- For clarification: If I use pins 0 and 1, I have heard that you cannot keep the Arduino plugged in with USB at the same time, and anything connected to these will need to be unplugged while uploading a sketch. Is this correct?
That is correct for a number of boards. It applies to the 328P based boards and the Mega. For debugging, the USB is also very useful. You can consider the use of software serial for the connected device while developing.
On boards with native USB (e.g. based on 32U4), the serial port is not used for communication with the PC so no need to disconnect.
PS The Mega has 4 serial ports, so you can always use e.g. another port.
sterretje:
That is correct for a number of boards. It applies to the 328P based boards and the Mega.
[...]
PS The Mega has 4 serial ports, so you can always use e.g. another port.
Good to know. I have an Uno right now, but considered a Mega in case I end up needing more ports. Looks like it has a lot of benefits, I will probably end up using that in the end.
For debugging, the USB is also very useful. You can consider the use of software serial for the connected device while developing.
I've mostly been working on developing everything to work fine before making the switch to using serial with the DIO ports, USB has been pretty helpful and easy to debug with. If I end up getting a Mega, software serial seems like it will be useful - right now on my Uno I don't have enough ports open, but the ability to use software serial might just be enough to convince me to change the type of Arduino I'm using to make developing it easier.
Avoid software serial in any form unless you NEED it.
The MEGA with four hardware ports should almost never require you use SWserial. The hardware ports are better in almost every way!
As well as the FT232 and similar chips, you can buy very low cost bidirectional TTL-to-RS232 interface boards on ebay etc, they simply connect to whatever serial pins you’re using and present a +/-5V RS232 port when you need it. (+/-12V is the original/official definition of RS232, but has been 5V compatible for 15 years or more).
ranjit-ao:
I've mostly been working on developing everything to work fine before making the switch to using serial with the DIO ports, USB has been pretty helpful and easy to debug with. If I end up getting a Mega, software serial seems like it will be useful - right now on my Uno I don't have enough ports open, but the ability to use software serial might just be enough to convince me to change the type of Arduino I'm using to make developing it easier.
SoftwareSerial is for those cases where you need serial communication with something but you do not have sufficient hardware serial ports.
Responding a last time because it looks like this thread has been wrapped up, and I have had my questions answered. I appreciate the fast and helpful responses. : )
I will try to avoid using the pins as per everyone's suggestions, since it seems they will cause a lot of issues. I think I'll get a Mega. A quick Google search for the hardware serial ports turns up "The Arduino Mega has three additional serial ports: Serial1 on pins 19 (RX) and 18 (TX), Serial2 on pins 17 (RX) and 16 (TX), Serial3 on pins 15 (RX) and 14 (TX)" which is more than enough, I'll do more research on it today.
lastchancename:
As well as the FT232 and similar chips, you can buy very low cost bidirectional TTL-to-RS232 interface boards on ebay etc, they simply connect to whatever serial pins you’re using and present a +/-5V RS232 port when you need it. (+/-12V is the original/official definition of RS232, but has been 5V compatible for 15 years or more).
These look like what I need, thank you. The actual wiring part is not my area of expertise, so interface boards like this will save me a headache for now.