# Three UART connections to an ATMega328?

I'm looking at the ATMega328p data sheet, and an Arduino Pin diagram, trying to determine if the chip can support three UART connections. I see that PD0 and PD1 are "USART" In and Out. So does that mean the other 10 or so Digital pins can be used for "UART" communications?

I have a need to connect three UART devices through the ATMega chip. The ATMega will forward traffic between two of the devices at a time, depending on which mode it's in.

• So non of the Arduenos supports 3 UART ? what about Embed instead of arduino? ok if i Use SPI, do i still need to use the Tx and Rx pin or no need then ?? – user15514 Oct 23 '12 at 14:36
• You should seriously consider using a different chip. While there are workarounds you won't pay much if anything more for a part with 3 hardware UARTs. – Chris Stratton Dec 14 '15 at 14:05

If you don't have enough hardware serial ports, you can use other IO pins for serial under software control. But, don't expect to get 115200bps...

http://arduiniana.org/libraries/NewSoftSerial/

• I wouldn't use SoftwareSerial for fast stuff / important data as well, but the documentation says "It is possible to have multiple software serial ports with speeds up to 115200 bps". Do you think they're just wrong? – Julian F. Weinert Sep 11 '16 at 15:25

It is true - only one serial port on the ATMega 328. You can do what the others suggested and use software-serial or you can use a multiplexer if you don't need your serial ports to be always on. Sparkfun has one that can be used for 3.3V here: http://www.sparkfun.com/commerce/product_info.php?products_id=8970

Basically, if there isn't constant traffic, especially if you only need to send messages or you will only receive one response for one command then you can use the multiplexer. Just switch to the device you want, send commands, wait for response, then switch to another device.

There is only one UART on the 328P. If your bandwidth is low you can do software emulation of a UART with some of the other digital pins. There is an Arduino library called NewSoftSerial that enables this functionality.

I'm new to SBC development, coming from Software Development, but you may want to look into the ATmega 2560 which i believe has 4 UARTs

You can add a dual UART with SPI or I2C interface. NXP makes one that I've used on boards. Around $4 from Digikey, it's cheaper than jumping up to a$12 Atmega2560 for a design, and offers more data buffering. https://www.nxp.com/products/analog/signal-chain/bridges/om6273-sc16is752-762-spi-ic-to-dual-uart-irda-gpio:OM6273?lang=en&lang_cd=en&