GPIO Pin # for RX2 and TX2 ? (Solved)

JacoFourie
Posts: 13
Joined: Mon Jan 22, 2018 7:54 pm

GPIO Pin # for RX2 and TX2 ? (Solved)

Postby JacoFourie » Thu Feb 15, 2018 7:27 pm

Hi.

I am using this ESP32 Dev Board.

http://www.uctronics.com/uctronics-esp- ... g-ide.html

I want to use a second serial connection (UART) using this code

Code: Select all

#include <HardwareSerial.h>

HardwareSerial MySerial(1);

MySerial.begin(19200, SERIAL_8N1, x, y);
What should x and y be to use RX2 and XT2 ?

I assume that the USB serial is connected to RX0 and TX0
Attachments
UART.JPG
UART.JPG (73.01 KiB) Viewed 62297 times
Last edited by JacoFourie on Sat Feb 24, 2018 5:45 am, edited 1 time in total.

JacoFourie
Posts: 13
Joined: Mon Jan 22, 2018 7:54 pm

Re: GPIO Pin # for RX2 and TX2 ?

Postby JacoFourie » Fri Feb 16, 2018 8:02 am

I read somewhere RX0 and TX0 is GPIO 1 and 3 and RX2 and TX2 is 16 and 17. Is that correct ?

JacoFourie
Posts: 13
Joined: Mon Jan 22, 2018 7:54 pm

Re: GPIO Pin # for RX2 and TX2 ?

Postby JacoFourie » Mon Feb 19, 2018 8:54 am

Anybody ??

User avatar
luisonoff
Posts: 40
Joined: Fri Feb 09, 2018 12:20 pm

Re: GPIO Pin # for RX2 and TX2 ?

Postby luisonoff » Mon Feb 19, 2018 10:06 am

Hello Jaco,
Each dev board is different. I suggest you look for an eschematic for that particular one, or use a multimeter to check where those pins are connected. Later you can use the ESP32 module datasheet to check what pin number it is.
BTW, if I am not mistaken, you can route UART2 pins (TX2-RX2) to any gpio pin of the ESP32 you want, in code.

mistergreen
Posts: 10
Joined: Tue Jan 23, 2018 4:56 pm

Re: GPIO Pin # for RX2 and TX2 ?

Postby mistergreen » Mon Feb 19, 2018 4:13 pm

RX0 = 3
TX0 = 1

try
RX2 = 16
TX2 = 17

JacoFourie
Posts: 13
Joined: Mon Jan 22, 2018 7:54 pm

Re: GPIO Pin # for RX2 and TX2 ?

Postby JacoFourie » Tue Feb 20, 2018 9:34 pm

Thanks. That did the trick.

grasvezel
Posts: 10
Joined: Mon Feb 12, 2018 4:54 pm

Re: GPIO Pin # for RX2 and TX2 ?

Postby grasvezel » Thu Feb 22, 2018 2:29 pm

One of the nice things about the ESP32 is that pins are not hard wired. So you can use different pins if you like, just like SoftwareSerial. The big difference is that it's not done in software, but the ESP32 rewires the UART to the pins you specify.

On the devboard I use for instance, de default pins used by UART1 are already in use to connect the flash chip. You can specify pins to use instead of the default ones with Serial1.begin() (or whatever name you gave your second serial port). In my case (unusual settings because I'm reading data from a smart electricity meter that uses 7E1, has only TX (so RX on my end) and produces an electrically inverted signal):

Code: Select all

HardwareSerial SerialSM(1);
SerialSM.begin(9600, SERIAL_7E1, 12, -1, true);
Hope that helps.

JacoFourie
Posts: 13
Joined: Mon Jan 22, 2018 7:54 pm

Re: GPIO Pin # for RX2 and TX2 ?

Postby JacoFourie » Sat Feb 24, 2018 5:44 am

Hi. I wanted to use the default pins marked RX2 and TX2 as they are on the board already. I know I can use any other pin but then I will run out of other pins as I am using the other pins for the UART and there are 2 pins already marked for that reason. The image I posted is from the DEV boards documentation. It would be nice if they just put in brackets the GPIO numbers of the pins as well.

I am controlling a actuator with a motor controller. I had to set-up the motor controller to communicate via TTL that is why it was ignoring me.
I took a TTL to serial USB adapter and connected it to GPIO16 and 17 and just did a simple test using putty to receive and send data to the ESP32 on that UART. Then I knew it was working fine on the ESP32 side and then I looked on the controller side and found it was set to work via USB and not TTL.

Thanks for the help all.

xam_gnaledrab
Posts: 1
Joined: Wed Jul 31, 2019 9:27 am

Re: GPIO Pin # for RX2 and TX2 ? (Solved)

Postby xam_gnaledrab » Wed Jul 31, 2019 1:26 pm

thanks! Works also for the SBC-NodeMCU-ESP32 board!

Who is online

Users browsing this forum: No registered users and 126 guests