Using a software serial port for Serial monitor output?

Hi everyone,
I have a library that requires a hardware Serial port for it's functions and my Arduino Uno only has one hardware Serial port. I would still like to use the Serial.print() functions to debug my program but it seems to use that same port.
Is there a way to create a software serial port and use it for printing debug messages to the Serial monitor and then use the hardware serial port for my library?

Thanks
Sam

Hi,

use an arduino mega, it has 3 hw serial .

Yes, sure
You need an external USB-UART converter, like this:

Connect it to arduino pins, on which you run a SoftwareSerial and read the data with Arduino Serial Monitor

Thanks. I did know there were other boards I could use, but I just happen to only have a Arduino UNO and I have always wondered about this. Would still like to know if it is possible or not, but thank you anyway.

Sam

If only for debug output, consider LCD or OLED with IIC (two-wire comm).

Why not use Software serial on the Uno for this project?

Using Rx0 and Tx0 will prove to be problematic.

turn the idea upside down, can you use software serial at 9600 baud for your other connection, leaving the onboard serial for Serial Monitor use? Even if you develop in this mode, and then at the end swap ports so you can crank up the baud rate to the device, this might work for you.
Otherwise, your basic answer is "no".

This is how you can go:
1. Connect UNO's Hardware Serial Port with the PC using a USB Port.
2. Connect UNO's of Software UART Port (SUART(2, 3)) with the PC using another USB Port. The connection must agree with Fig-1.


Figure-1:

3. Upload the following sketch in UNO.

#include<SoftwareSerial.h>
SoftwareSerial SUART(2, 3);

void setup()
{
  Serial.begin(9600);
  SUART.begin(9600);
}

void loop()
{
  byte n = Serial.available();
  if (n != 0)
  {
    char ch = Serial.read();
    SUART.print(ch);
  }
}

4. Open Serial Monitor-1 with Newline option for Line ending box and Bd = 9600.
5. Open IDE-2 and detect the SUART Port at the correct virtual COM Port.
6. Open Seral Monitor-2 at Bd = 9600 from IDE-2.
7. Enter "Hello World" in the InputBox of SM-1 and then click on the Send Button.
8. Check that the message has appeared in the OutputBox of Serial Monitor-2.

Why doing it so complicate?????
Arduino -TTL , TTL - RS232, than RS232 to USB ???

Why not use standard USB-UART converter?
https://www.amazon.com/HiLetgo-FT232RL-Converter-Adapter-Breakout/dp/B00IJXZQ7C/

1 Like

That would be good if I would have USB <-----> TTL converter.

And what's the problem, It costs starting from two dollars ...

1 Like

I have TTL/RS232 and RS232/USB converters; so, I have only the option of connecting them back-to-back and then test the setup.

Maybe you should check what the OP has available ?

1 Like

@SamJBoz Did you consider post #7?

1 Like

The library only uses a hardware serial port. I guess it was the way the library was written. If I try to create a software serial port the compiler complains.

I made my life simpler and bought an Arduino Mega 2560 with 3 hardware serial ports.
Thank you all for your suggestions. I thought there might be a simple solution for the Arduino Uno, but I guess buying the 2560 board is probably the simplest of all.

As you haven't posted your sketch and the compiler output, it's very difficult to help you with that :wink:

But OK, you bought a different board and your problem is solved :+1:

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.