How to change ESP32 Hardware Serial Ports pin inside Mongoose

Hi Guys,

By default, Mongoose configure ESP32 HardwareSerial Pins as follows:

UART 0: Rx: 3, Tx: 1, CTS: 19, RTS: 22
UART 1: Rx: 25, Tx: 26, CTS: 27, RTS: 13
UART 2: Rx: 16, Tx: 17, CTS: 14, RTS: 15

I would like to change UART 1 pins to:

UART 1: Rx: 34, Tx: 32

How can I do this on mos.yml file ?

I will appreciate any directions.

Thank you

Regards

José Luiz

You can do it in your program, not in mos.yml
Example

1 Like

Hi nliviu,

I appreciated your kindly help.

I follow your suggestion and I could change serial pins for ESP32 UART1 inside the code as follow:

//HardwareSerial Serial ATMEGA (RX=GPIO34 , TX=GPIO32);
int uart_atmega = 1;
struct mgos_uart_config ucfg_1;
mgos_uart_config_set_defaults(uart_atmega, &ucfg_1);
ucfg_1.baud_rate = 115200;
ucfg_1.num_data_bits = 8;
ucfg_1.parity = MGOS_UART_PARITY_NONE;
ucfg_1.stop_bits = MGOS_UART_STOP_BITS_1;
ucfg_1.dev.tx_gpio = 32;
ucfg_1.dev.rx_gpio = 34;

Thank You Very Much for your help, it makes possible to finish my project.

Best Regards

José Luiz

Hi Jose,
Can you please tell me in what file did you put that code, in order for it to change the UART pins? is it mos.yml or init.js file? thank you