I have been seraching around the answer for this question, but it always throws me again to the same idea of using softwareSerial library. I am very skeptical that arduino can really receive two simultaneous serial streams at the same time; as I understand that only one pin has a serial buffer and all other ports need to generate an interrupt in order to receive a message.
I am planning to make a hardware that will have four serial inputs, that will be receiving many signals, with a high likelihood of two signals coming at the exact same time. Should I remain skeptical of arduino serial multitasking capabilities and buy serial buffer IC's, or I can trust software serial to listen four serial ports?
Software serial CANNOT listen to more than one at a time.
But many Arduinos have more than one hardware serial port. The Mega and Due have 4. The Teensy 3.5 and 3.6 have 6 hardware serial ports which can send and receive data simultaneously at any speed.
I believe a 2560 based board can do 4 serial ports at once as there are 4 sets of internal hardware to handle the inputs.
Unless you are running at really high speeds, like 250000 bps, you should be okay.
Your "serial buffer IC" would be a part like these
with an SPI or I2C interface and with larger hardware buffers than what the Arduino does in software.
thanks! this is handy information. I just discovered one can thanks by "adding karma"
So in general if using two serial inputs, the software serial one should interrupt while the hardware serial should always give time for the software serial to receive. And over all, one must never use more than one software serial input.
Also it is far more expensive to buy three serial buffers than one Arduino mega instead of a Uno.
An Atmega 328 connected to an Uno using SPI is a cheap way of adding extra HardwareSerial ports. Or, even cheaper is an Attiny 1634. And they come with SRAM that can buffer the incoming messages.
Joaquin:
So in general if using two serial inputs, the software serial one should interrupt while the hardware serial should always give time for the software serial to receive. And over all, one must never use more than one software serial input.
If you have multiple hardware serial ports, you do NOT use SoftwareSerial to control/use them. The four ports on e.g. Mega are Serial, Serial1, Serial2 and Serial3 and you use them in the same way as you use the normal Serial.
E.g
void setup()
{
Serial.begin(115200);
Serial3.begin(9600);
}
void loop()
{
// print hex value of received characters on Serial3 to serial monitor
if(Serial3.available() != 0)
{
Serial.print(Serial3.read(), HEX);
}
}