I got into a project where I have to find the way to be able to connect an Arduino to several devices (ideally +20) , each one with its own UART, and communicate with them. Is there some way to achieve this goal? Arduino Uno has 1 UART, and Arduino Mega has 4 UART´s, but that´s pretty far from 20 devices. Is there any way to achieve this, maybe with multiplexing?
Unfortunately the devices from where I have to read the information do not provide I2C communication. It has to be done through serial port connection.
Some idea?
Are the serial connections TTl or ±12V (RS232)? Can your query each device when you want their data? Is the data fixed length, delimited? There should be a way to multiplex. I haven't done it with asynchronous but I did a project that multiplexed 8 synchronous devices.
Use an external UART, like the MAX3110 or MAX3111. They use an SPI interface to the Arduino. You'll have to use a multiplexer for the slave select to get that many devices on your SPI bus, but it is theoretically possible.
NXP also has some devices that are I2C or SPI, but they're 3.3V parts.
Another option is to use an Arduino as a UART peripheral. You have to write the library on each end, though.
kg4wsv, you are suggesting adding 20+ uarts for the arduino to control? That makes no sense.
An RS485 transmitter/receiver for duplex comms, or a transceiver for simplex, is all that is needed.
kg4wsv, you are suggesting adding 20+ uarts for the arduino to control?
Yep.
That makes no sense.
It's what the OP asked for.
Besides, I use rack mount boxes that are 16 port RS232 to USB adapters at work, so it's not much of a stretch for me to imagine someone needing a crapload of serial ports.
An RS485 transmitter/receiver for duplex comms, or a transceiver for simplex, is all that is needed.
If he's building an entire system from scratch, I would agree. But maybe he's got a bunch of COTS devices that already exist and only have RS232 that he needs to interface. Again, not hard for me to imagine, because I've got the same problem.
Your RS485 may be what he needs, but my pile of MAX3110s is what he asked for.
mguerrerop:
I got into a project where I have to find the way to be able to connect an Arduino to several devices (ideally +20) , each one with its own UART, and communicate with them. Is there some way to achieve this goal? Arduino Uno has 1 UART, and Arduino Mega has 4 UART´s, but that´s pretty far from 20 devices. Is there any way to achieve this, maybe with multiplexing?
Are they all transmitting at once, or do you poll them? How about a 16-port multiplexer or two?
You might need four (2 for input and 2 for output) but it depends if you are just sending or just receiving, or both.