Page 1 of 1

E (100167) uart: uart_set_pin(559): tx_io_num error

Posted: Wed Aug 17, 2022 9:36 pm
by cederom
Hello world :-)

I have problem running UART in the following configuration:

Code: Select all

UART(1, tx=19, rx=35, baudrate=115200)
I get this error:

Code: Select all

E (100167) uart: uart_set_pin(559): tx_io_num error
According to QuickRef (https://docs.micropython.org/en/latest/ ... serial-bus):
Any GPIO can be used for hardware UARTs using the GPIO matrix, so to avoid conflicts simply provide tx and rx pins when constructing.
The setup is:

Code: Select all

MicroPython v1.18 on 2022-01-17; ESP32 module with ESP32
Any hints welcome :-)

Re: E (100167) uart: uart_set_pin(559): tx_io_num error

Posted: Thu Aug 18, 2022 2:59 am
by marcidy
no problems on v1.19.1 using an ESP32 devkit-c-v4

Code: Select all

>>> from machine import UART
>>> u = UART(1, tx=19, rx=35, baudrate=115200)
>>> 

Re: E (100167) uart: uart_set_pin(559): tx_io_num error

Posted: Thu Aug 18, 2022 3:04 am
by cederom
Well, turned out to be my bug :-) Some part of the code that was defining the hardware on the fly swapped 19 with 35 and obviously IO35 can be input only :-) Sorry for the noise!! :-)

By the way, I have managed to successfully use UART1 to serve two different devices attached to a different GPIO ports, one at time, by calling

Code: Select all

uart.init()
with different parameters, and that makes code portable among ESP32 and ESP32-C3 (C3 has only two UART, one used for System Console) :-)

Note:

Code: Select all

uart.deinit()
does not only turns off the port but also destroys the object and it cannot be initialized again :shock: I have proposed a PR that updates documentation a bit: https://github.com/micropython/micropython/pull/9067.