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

All ESP32 boards running MicroPython.
Target audience: MicroPython users with an ESP32 board.
Post Reply
User avatar
cederom
Posts: 16
Joined: Tue Oct 26, 2021 1:37 am
Contact:

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

Post by cederom » Wed Aug 17, 2022 9:36 pm

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 :-)
--
CeDeROM, SQ7MHZ, https://www.tomek.cedro.info

marcidy
Posts: 133
Joined: Sat Dec 12, 2020 11:07 pm

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

Post by marcidy » Thu Aug 18, 2022 2:59 am

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)
>>> 

User avatar
cederom
Posts: 16
Joined: Tue Oct 26, 2021 1:37 am
Contact:

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

Post by cederom » Thu Aug 18, 2022 3:04 am

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.
--
CeDeROM, SQ7MHZ, https://www.tomek.cedro.info

Post Reply