SerialSoftware

Hello,

I would like to use SerialSoftware librarie, but I don’t understand how to see what datas have been sent.
when I open the seriel monitor, I only see what happen on Serial port and not what happen on software serial port.
Could you help me please ?
Thanks for advance
Best ragards
Fabien

#include <SoftwareSerial.h>

SoftwareSerial dbgSerial(10, 11);

void setup() {
Serial.begin(115200);
Serial.setTimeout(10000);
dbgSerial.begin(9600);
}

void loop() {
//OK, I can see this text on the monitor
Serial.println(“Test of text 1”);

//But I can’t see this text. There is nothing displayed on the monitor
dbgSerial.println(“Test of text 2”);

}

In your program SoftwareSerial communicates on pins 10 and 11 and HardwareSerial (Serial) communicates on Pins 0 and 1 and through the USB connector to your PC.

If you want the output of SoftwareSerial to appear on your PC then you need to connect a USB-TTL cable to your PC and to Pins 10, 11 and GND. Of course this assumes that you do not want SoftwareSerial to connect to anything else.

If SoftwareSerial is being used to connect to something else then the usual way is to receive a message using SoftwareSerial and then send it to your PC using HardwareSerial.

Have a look at the examples in Serial Input Basics - simple reliable ways to receive data.

...R

Hello,

Thank you for your quick reply.
I understand my mistake :slight_smile:
I will try with the usb-ttl wire.
Thanks
Fabien

@OP

First of all, you need to understand the concept of Software UART Port (SUART) and then the procedures of serial data exchange using this port. The following diagram of Fig-1 may help you to understand these concepts.
uartUNO-3x.png
Figure-1: Connection diagram between UNO and NANO using SUART Ports

1. The ATmega328P MCU of the UNO Board has only one hardware UART Port (UART). It is permanently connected with PC to support SM1 (Serial Monitor-1) and Arduino IDE.

2. The ATmega328P MCU of the NANO Board has only one hardware UART Port (UART). It is permanently connected with PC to support SM2 (Serial Monitor-2) and Arduino IDE.

3. If we want to exchange data between UNO and NANO using UART Ports, we may connect the UART Ports of both Arduinos; but, this kind connection is not recommended as they usually do not work.

4. The solution is to use a Software UART (SUART) Port which is created when the user includes the following codes in his sketch:

#include<SoftwareSerial.h>
SoftwareSerial dbgSerial(10, 11);  //(SRX, STX)
dbgSerial.begin(9600);

5. All the commands/methods of the UART Port are equally applicable for the SUART Port except that the void serialEvent() procedure is exclusively reserved for the hardware UART Port.

6. The Fig-1 says that serial communication among SM1, UART(1), SUART(1), SUART(2), and SM2 will happen in the following ways.
(1) Send a character (say, A) from the InputBox of SM1. It will arrive at UART(1) Port of UNO.
(2) Read the character from UNO's UART Port.
(3) Write the character to the SUART(1) Port of UNO. The character will arrive at SUART(2) Port of NANO.

(4) Read the character form SUART(2) Port of NANO.
(5) Write the character to the UART(2) Port of NANO.
(6) Check that the character A has appeared on the OutputBox of SM2.

7. Convert the events of Step-6 into Arduino Codes. Upload the codes into UNO and NANO as needed. Please, post the results.

uartUNO-3x.png

5V Logic (i.e. Uno Board): Amazon.com: EZSync FTDI chip USB to 5v TTL UART Serial Cable, Connector end, 1.5m, TTL-232R-5V Compatible, EZsync008 : Electronics

3.3 V Logic: https://www.amazon.com/JBtek-WINDOWS-Supported-Raspberry-Programming/dp/B00QT7LQ88/ref=pd_lpo_vtph_147_bs_lp_t_1?_encoding=UTF8&psc=1&refRID=M6SC5JD3SRD38V813CSA

Hello,

Thank you very much for your answers.
It works fine now :slight_smile:
Good evening
Fabien