Print to uart1 only

All ESP8266 boards running MicroPython.
Official boards are the Adafruit Huzzah and Feather boards.
Target audience: MicroPython users with an ESP8266 board.
Post Reply
lvx_xvl
Posts: 5
Joined: Sun Jul 26, 2020 11:45 am

Print to uart1 only

Post by lvx_xvl » Wed Mar 09, 2022 7:55 pm

Hi all,

Although the title of this topic may sound simple, I cannot find a clear explanation on how this should work.

A print() command in the MicroPyhton code can end up on several places: REPL, WebREPL, Tx/Rx pins. But how to prevent a print output to any of these locations? I'm a bit lost on this specific topic.

Why? you may ask!!! Well I'm using a Wemos D1 mini (ESP8266) and it has (to my knowledge) 2 UART's: UART0 and UART1. If I understand the documentation correctly the UART0 is the same as what is received via the USB connector, and UART1 is the second UART that is available. Sadly the second UART has a handicap, it can only do Tx. Which, in my case, is just fine!!!

I need UART0, via the pins Tx and Rx (GPIO1 and GPIO3), to talk to my device and I can utilise UART1's Tx pin (GPIO2) for printing.

Now the question: How? How do I setup UART1 to be the only way out for the print() command, or UART1 and the WebREPL? So that the print() doesn't pollute the UART0 pins with data the device on the other end doesn't understand and doesn't need to have.

Best regards,
LVX

Post Reply