Not enough serial ports on Arduino Mega -- Options?

In summary, this person is working on a project involving multiple Arduinos and wants to use RS232 as their communication protocol. They are considering using RS485 but are worried about the reliability of the system.
  • #1
taylaron
Gold Member
397
1
Greetings!
I'm working on a project involving multiple different Arduinos spaced about 500 feet apart. I have a master Arduino which I plan on being an Arduino Mega and 5-8 separate slave Arduinos (probably Arduino Nanos) which feed basic data like switch values to the master. I would like to use RS232 as my communication protocol, using 1 serial port on the master Arduino per slave. My problem is there are only 4 serial ports on the Arduino Mega. I was curious if anyone knows of a way to rig more digital I/O pins as serial outputs or if there is something I hadn't considered.

note: I'm fixed on using wired communication, and my speed doesn't need to be very high- 9000 baud is plenty.

I had considered using RS485, but I'm trying to minimize device size and hardware as well as keeping the system simple.

Kind regards
 
Engineering news on Phys.org
  • #2
Have you considered a more dispersed topology? Perhaps you can use four of the slaves to multiplex commands to the others? If not, how about extra multiplexing slaves colocated with the master? Or you could buy or make an RS-232 multiplexing switch.

This is a problem that's been solved many times. I'm sure an internet search will yield lots of options.
 
  • #3
Your main problem will be that RS232 is only spec'd to 50ft, sure it can be longer (at slower speeds) and faster (at short distances) but it's designed with high impedance drivers of greater than 3k Ohms. To drive 100+ foot cables you should use a RS4XX (multi-drop) interface or a similar Line Driver if you want to stay pure serial data and still have reliable connections.

http://www.rs485.com/rs485spec.html
8 port repeater hub RS232 to RS485
http://www.rs485.com/pmhubx8.html
 
Last edited:
  • #5
Lookk into CAN bus - there are some shields, and other low cost options - it is a multi-point bus, and runs with a master, so you should not need to use up the ports. I would first consider the full function shield for the master and the low cost ports for the slaves.
As for the 500ft -- where - that will become a large antenna - likely to pick up noise and if any lightning events - can fry what it is connected to without the proper precautions, as well and pay attention to the power source for each, surprising voltage differences can occur over 500ft.
 
  • #6
Way back in the day I created an RS-485 multi-master network with a "random delay backoff" as workaround for collisions. A slow cheap ethernet back when ethernet was new.

But over long distances the common mode voltages and ground faults made it unreliable. Even within one room, there can be significant ground spiking. Especially if there are large motors, elevators, etc in the building.

That's why ethernet uses transformers. But, you need to use a coding method like Manchester, 8b10b or longer (like 64b66b), etc to send "AC" data through the transformer.

canbus has +-12V common mode, and requires you only ground at 1 point or use digital isolators. The http://www.ti.com/lit/ds/slls629k/slls629k.pdf looks like a REALLY cool part to get around AC coding. But, I've never worked with it and don't know what its real issues are. Anybody?
 
Last edited by a moderator:
  • #7
Does the Arduino have an ethernet connection? CAT5 cable is cheap, and cable costs sound like an issue.
 
  • #8
Thanks for the input everyone! I decided to stick with dedicated RS232 communication through network cables for each of my devices. I'm sure I could've done something with RS485, but I wanted to keep the system simple. I was going to use an arduino Mega anyway, so there posed no problems with available ports.

I appreciate your input!
 

Related to Not enough serial ports on Arduino Mega -- Options?

1. What is the Arduino Mega?

The Arduino Mega is a microcontroller board based on the ATmega2560. It has 54 digital input/output pins, 16 analog inputs, 4 UARTs (hardware serial ports), a 16 MHz crystal oscillator, a USB connection, a power jack, an ICSP header, and a reset button. It is commonly used in electronics projects for its versatility and easy programming.

2. Why does the Arduino Mega have a limited number of serial ports?

The Arduino Mega has a limited number of serial ports because it is a microcontroller board designed for small and medium-sized projects. It is not meant to be used in complex systems that require a large number of serial ports.

3. What are the options for adding more serial ports to the Arduino Mega?

There are a few options for adding more serial ports to the Arduino Mega. One option is to use a software serial library, which allows you to use any digital pins on the board as additional serial ports. Another option is to use a serial multiplexer, which allows you to connect multiple devices to a single serial port.

4. How do I know if I need more serial ports on my Arduino Mega?

If you are running out of serial ports on your Arduino Mega and need to connect more devices, then you may need to add more serial ports. Another indication is if you are receiving an error message stating that there are not enough serial ports available.

5. Are there any limitations to using additional serial ports on the Arduino Mega?

There are a few limitations to using additional serial ports on the Arduino Mega. For example, using software serial can cause timing issues and may not work well with high-speed communication. Additionally, using a serial multiplexer may add some complexity to your project and require additional wiring. It's important to carefully consider your project's needs before deciding to add more serial ports to your Arduino Mega.

Similar threads

Replies
5
Views
983
  • Electrical Engineering
Replies
5
Views
21K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
5
Views
5K
  • Engineering and Comp Sci Homework Help
Replies
2
Views
2K
  • Computing and Technology
Replies
1
Views
6K
  • Programming and Computer Science
Replies
6
Views
2K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
1
Views
2K
  • Electrical Engineering
Replies
6
Views
1K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
2
Views
14K
Replies
5
Views
2K
Back
Top