Dismiss Notice
Join Physics Forums Today!
The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

Not enough serial ports on Arduino Mega -- Options?

  1. Jun 4, 2015 #1


    User Avatar
    Gold Member

    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
  2. jcsd
  3. Jun 4, 2015 #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.
  4. Jun 4, 2015 #3


    User Avatar
    Science Advisor

    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.

    8 port repeater hub RS232 to RS485
    Last edited: Jun 4, 2015
  5. Jun 6, 2015 #4


    User Avatar
    Gold Member

  6. Jun 9, 2015 #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 with out the proper precautions, as well and pay attention to the power source for each, surprising voltage differences can occur over 500ft.
  7. Jun 10, 2015 #6


    User Avatar
    Gold Member

    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 [Broken] 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: May 7, 2017
  8. Jun 11, 2015 #7
    Does the Arduino have an ethernet connection? CAT5 cable is cheap, and cable costs sound like an issue.
  9. Jun 17, 2015 #8


    User Avatar
    Gold Member

    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!
Share this great discussion with others via Reddit, Google+, Twitter, or Facebook