# Arduino UNO Serial Question

#### Old Steve

Jul 23, 2015
734
I'm unsure of a point regarding serial comms on an Arduino UNO. My Arduino hasn't arrived yet, so I can't do any experimenting to find out the hard way.

I need to receive serial raw data from one remote device, process it, then send the processed data on to another remote device, again using serial comms.

There's a built-in UART connected to pins 0 and 1, which I can use for one serial stream.
For the second, is it possible to use the Arduino Software Serial Library, utilising whichever pins I want, or is that library only for the Mega?

Or am I out of luck? If it is impossible with a UNO, I can use a PIC with PICBasic Pro and set up software serial on any (or all) pins, but I'd prefer to use the Arduino for this.

Edit: Like so:-
Code:
#include <SoftwareSerial.h>

SoftwareSerial mySerial(10, 11); // RX, TX

void setup()
{
// put your setup code here, to run once:
Serial.begin(9600);
mySerial.begin(19200);
}

Last edited:

#### Old Steve

Jul 23, 2015
734
Just thinking about it, I guess there's an alternative - use the inbuilt RX pin to receive from one device and the TX pin to send the processed data to the other. (I won't be doing any software handshaking, so it wouldn't hurt to split the pins.)

I'd still like an answer to my original question though, if anyone knows about the software serial library with UNO.

#### Harald Kapp

##### Moderator
Moderator
Nov 17, 2011
12,608
It states here:
The SoftwareSerial library has been developed to allow serial communication on other digital pins of the Arduino, using software to replicate the functionality (hence the name "SoftwareSerial"). It is possible to have multiple software serial ports with speeds up to 115200 bps. A parameter enables inverted signaling for devices which require that protocol
but I like your second idea much more.

#### Old Steve

Jul 23, 2015
734
It states here:

but I like your second idea much more.
Yes, I read that Harald, but it didn't say 'which' Arduino. For now, until my board arrives, I'm assuming it means all of them, and writing some code accordingly.
(It compiles OK with the board set to "UNO" under "Tools".)

Which idea, using a PIC or splitting the pins?

#### Harald Kapp

##### Moderator
Moderator
Nov 17, 2011
12,608
Splitting the pins. Aöthough you then are stuck with the same baudrate for both Tx and Rx whereas using two separate UARTS you could have different baudrates - if that matters at all.

#### Old Steve

Jul 23, 2015
734
Splitting the pins. Although you then are stuck with the same baudrate for both Tx and Rx whereas using two separate UARTS you could have different baudrates - if that matters at all.
Good point Harald.
There aren't two UARTS though. Just the one on a UNO. The second serial stream would use software serial.

Just thinking, in my application I could split the pins and have two different baud rates. The raw data will only arrive once per second. More than enough time in between to call Serial.end(), then Serial.begin() again with a different baud rate.
(Luckily, for this application, I know exactly when to expect new data to arrive. )

#### Harald Kapp

##### Moderator
Moderator
Nov 17, 2011
12,608
There aren't two UARTS though.
I'm aware of this, I was referring to the UART function regardless of the implementation in HW or SW.

In that case you could use the hardware UART for the fast transmission to relief the CPU from servicing a fast SW-UART and use the SW-UART for the slow connection which would not impose that much CPU load due to the slow speed.

#### Old Steve

Jul 23, 2015
734
I'm aware of this, I was referring to the UART function regardless of the implementation in HW or SW.
I thought you might have been, but just thought I'd make it clear.

In that case you could use the hardware UART for the fast transmission to relief the CPU from servicing a fast SW-UART and use the SW-UART for the slow connection which would not impose that much CPU load due to the slow speed.
Yep, my thoughts exactly. I'll use 9600 baud in, 19200 baud out.
I could even set a timer, to produce aninterrupt on overflow, to ensure I didn't miss any input data packets.

Edit: I'll dedicate the Arduino to this. It's only purpose will be to receive data packets, quickly process them, pass them on, then back to the receiving/processing. Even the interrupt will be overkill and not needed, just thinking about it. I wish that Arduino would hurry up and get here. There's only so much I can do in the simulator.

Last edited:

Replies
3
Views
859
Replies
8
Views
2K
Replies
13
Views
1K
Replies
4
Views
3K
Replies
0
Views
1K