Use SoftSerial and CP2102 USB to TTL

Hello,
I am trying to use a SoftwareSerial on pin 2 & 3 and connect them to my PC through an UART to USB Converter (on it mounts a CP2012).

This is the code of my sketch:

#include <SoftwareSerial.h>

SoftwareSerial mySUART (2, 3);   //DPin-2 will work as SRX-pin, and DPin-3 will work as STX-pin; S for soft

void setup() {
  // put your setup code here, to run once:
  Serial.begin(9600);
  
 
  mySUART.begin(9600);   //data transfer rate of SUART Port = 9600 Bd
}

void loop() {
  // put your main code here, to run repeatedly:
  Serial.println("2");
  mySUART.println("r");
}

I try to connect with Putty but I don’t see nothing!

I tried different times to swap TX and RX between Arduino and the converter but nothing to do! Wh? :slightly_smiling_face:

And which 'Arduino' are you using ?

srnet:
And which 'Arduino' are you using ?

Right, sorry.. It's an arduino UNO

I tried your code on my Uno with a CP2101 based FTDI (USB - serial converter) connected Uno RX (pin 2) to FTDI TX and Uno TX (pin 3) to FTDI RX. FTDI ground to Uno ground. Vcc of FTDI not connected. I did put a 500 millisecond delay in the loop() function so as to not flood the serial output. I get a steady stream of 'r' in PUTTY.

If it still does not work check your wiring. Check the settings in PUTTY.

groundFungus:
I tried your code on my Uno with a CP2101 based FTDI (USB - serial converter) connected Uno RX (pin 2) to FTDI TX and Uno TX (pin 3) to FTDI RX. FTDI ground to Uno ground. Vcc of FTDI not connected. I did put a 500 millisecond delay in the loop() function so as to not flood the serial output. I get a steady stream of 'r' in PUTTY.

If it still does not work check your wiring. Check the settings in PUTTY.

It still doesn't work. Should I get 5 V from the 5V of the converter when connected to the PC? Maybe I can power on my arduino from this 5V, if it doesn't turn on maybe the chip is broken

If you have the Uno connected (and powered) by USB you do not want to connect the Vcc on the FTDI to the Uno. That could have the 2 power supplies fighting each other.

If you unplug the Uno from USB, you can connect the FTDI 5V to the Uno 5V pin and it should work. I just tested it and I get the 'r' in PUTTY when connected to the FTDI serial port.

Do you have the ground of the FTDI connected to Uno ground?

Are you sure that RX and TX are crossed? That is RX to TX and TX to RX.

My setup is connected exactly as i described. And it works.

groundFungus:
If you have the Uno connected (and powered) by USB you do not want to connect the Vcc on the FTDI to the Uno. That could have the 2 power supplies fighting each other.

If you unplug the Uno from USB, you can connect the FTDI 5V to the Uno 5V pin and it should work. I just tested it and I get the 'r' in PUTTY when connected to the FTDI serial port.

Do you have the ground of the FTDI connected to Uno ground?

Are you sure that RX and TX are crossed? That is RX to TX and TX to RX.

My setup is connected exactly as i described. And it works.

OK NOW IT WORKS! I discovered first that RXD and TXD are already swapped on the board of the converter (I connected pin 2 to the RX of the converter), then I discovered that the cable I was using were broken (can dupont cables be broken (?))
Anyway, any last question: do you know the output voltage of the converter on the transmission line? If it's 3V3 or 5V, thank you

On mine the RX and TX are at 3.3V, measured to ground, when idle. No guarantee that yours is the same. Best to measure.

gabriele97:
I discovered first that RXD and TXD are already swapped on the board of the converter (I connected pin 2 to the RX of the converter

then I discovered that the cable I was using were broken

So you swaped the TX and RX, a good thing to try, but it made no difference because the cables were faulty.