Not enough serial ports on Arduino Mega -- Options?

Click For Summary
SUMMARY

The discussion centers on the limitations of the Arduino Mega's serial ports when connecting multiple slave Arduinos, specifically Arduino Nanos, for a project requiring RS232 communication. The Arduino Mega has four serial ports, which is insufficient for the proposed setup of 5-8 slaves. Suggestions include using RS485 for longer distances and multiplexing techniques to manage multiple connections. Ultimately, the user decided to maintain a dedicated RS232 setup using network cables to simplify the system.

PREREQUISITES
  • Understanding of Arduino Mega and Arduino Nano specifications
  • Knowledge of RS232 and RS485 communication protocols
  • Familiarity with multiplexing techniques in serial communication
  • Basic principles of electrical noise and grounding in long-distance communication
NEXT STEPS
  • Research RS485 communication and its advantages over RS232 for long-distance connections
  • Explore multiplexing methods for managing multiple serial connections on microcontrollers
  • Investigate CAN bus implementation and available shields for Arduino
  • Learn about proper grounding techniques and electrical noise mitigation in long-distance wiring
USEFUL FOR

Electronics hobbyists, Arduino developers, and engineers working on multi-device communication systems, particularly those requiring long-distance wired connections.

taylaron
Gold Member
Messages
391
Reaction score
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
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.
 
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:
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.
 
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:
Does the Arduino have an ethernet connection? CAT5 cable is cheap, and cable costs sound like an issue.
 
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!
 

Similar threads

Replies
5
Views
2K
  • · Replies 5 ·
Replies
5
Views
21K
  • · Replies 5 ·
Replies
5
Views
5K
  • · Replies 1 ·
Replies
1
Views
7K
  • · Replies 2 ·
Replies
2
Views
15K
  • · Replies 2 ·
Replies
2
Views
2K
  • · Replies 6 ·
Replies
6
Views
3K
  • · Replies 1 ·
Replies
1
Views
3K
  • · Replies 6 ·
Replies
6
Views
2K
  • · Replies 5 ·
Replies
5
Views
2K