using software serial in Arduino

Hello everyone,

Can I use more than one software serial at the same time? Currently I am using one hardware serial and one software serial but now I need to connect one more serial device and I was wondering if i could use more than one software serial at once. Can two software serial list/transmit at the same time? I haven't tried this since I don't have the Arduino with me now, I will do it later so in the mean time I wanted to know what to expect when I do my test.

cheers

It's pretty clear in the documentation for SoftwareSerial. Two can transmit but only one can listen at a time. AltSoftSerial has other, slightly different limitations.

SoftwareSerial is a big resource hog. Running two at once doesn't leave much time for your program to do any real work. Switching to an Arduino with more than one hardware serial, like Micro, Mega or Teensy will usually be required.

Two instances of SoftwareSerial do not really work. Only one of them can listen or transmit at any one time.

There is another library called AltSoftSerial that may allow more than one instance.

Another possibility (but I have not tested it) is that my Yet Another Software Serial will work alongside SoftwareSerial.

However the real answer is to use a Mega which has 4 HardwareSerial ports.

...R

It kind of depends on what you mean by "at the same time".

With hardware serial you can transmit via two different pins and both transmissions will proceed asychronously via interrupts. But SoftwareSerial transmissions are not interrupt driven. Each transmission is sent in its entirety before a new one can begin, before any other code can execute. Even ISRs are delayed since interrupts are disabled by SoftwareSerial for 9/10 of the time it takes to send each character.

Thanks for the suggestions guys,

I am not thinking of using a Arduino with two hardware serial ports and one software serial. This must allow me to listen/transmit from all the three ports at the same time right?

not == now?

Which Arduino?

Hello MorganS,

Thanks for correcting me :slight_smile:

I am actually thinking of using a Controllino MAXI (http://controllino.cc/product/controllino-maxi/).

That looks like a very expensive Arduino, but I can see why that might be useful in certain environments.

You do realize that RS232 is different to TTL serial? What plugs into the first two RS232 ports is different to what plugs into a spare pair of digital pins running SoftwareSerial.