EspSerial(2, 3); // RX, TX

I want to connect an ESP-01 to an Arduino Uno board, and I want to use software serial. I am confused by this line in the example code provided by Blynk:
EspSerial(2, 3); // RX, TX

Does that mean I should connect:
ESP RX to Arduino pin 2
ESP TX to Arduino pin 3
or is it vise versa?

Think like how sound travels from your mouth to another’s ear… TX → RX

Just search this forum for the many, many, many other topics and explanations about ESP-01 & Arduino.

I understand TX -> RX. The problem is, this line of code is vague…
EspSerial(2, 3); // RX, TX
… it could mean that pin 2 is the Arduino RX, or it could mean that I am supposed to connect ESP-RX to pin 2.
ESP RX to Arduino pin 2
ESP TX to Arduino pin 3
Is this correct?

It means that the software serial Rx pin on the Arduino will be pin 2, and the software serial Tx pin on the Arduino will be pin 3.
You’ll connect the ESP-01 Tx pin to pin 2 on the Arduino and ESP-01 Rx pin to pin 3 on the Arduino.

But. as @Gunner said, it you’d looked at wiring schematics and code in other threads you would have seen that this was the case. You would also have seen that you need to limit the software serial baud rate to 9600 and that the ESP-01 needs to have this same baud rate set via and AT command.
You would also have found discussions about the fact that it’s better to use hardware serial to link the Arduino and ESP-01 as this allows you to use a faster baud rate, but it requires a USB to serial adapter to allow you to see the software serial debug messages on your PC.

Plus, of course, you’d have seen all the advice to throw away your Arduino and ESP-01 and use a Wemos D1 Mini instead :grin:


It is a line of code… you want clarity??.. best stay away from programming :stuck_out_tongue:

It means that the declaration EspSerial will be used in the future to indicate that pin 2 is the Arduino’s Soft Serial port for RX and pin 3 is the Arduino’s SoftSerial port for TX.

As I already specified from your last post… your answer was your “vise versa” option, but now you reverse the question… now that is confusing :stuck_out_tongue: The answer is NO :wink:

Thanks guys. It is no longer vague.
For anyone in the future who stumbles onto this thread, if you are using software serial for an ESP module, and have this line of code:
EspSerial(2, 3); // RX, TX

Connect ESP TX to Arduino pin 2
Connect ESP RX to Arduino pin 3 (through a voltage divider or level shifter)

Of course, that line of code can and will change depending on the chosen pins and/or the board you use :wink:

Also… just some of the topics of relevance in this forum…

etc, etc…

And of course on the Web…