UART not working with today's version of micropython

RP2040 based microcontroller boards running MicroPython.
Target audience: MicroPython users with an RP2040 boards.
This does not include conventional Linux-based Raspberry Pi boards.
Tinus
Posts: 40
Joined: Sun Feb 14, 2021 4:53 pm

Re: UART not working with today's version of micropython

Post by Tinus » Thu Apr 15, 2021 11:47 am

Thank you very much, I will try that.

Tinus
Posts: 40
Joined: Sun Feb 14, 2021 4:53 pm

Re: UART not working with today's version of micropython

Post by Tinus » Thu Apr 15, 2021 1:46 pm

No that hasn't solved the problem.

I set the txBuf to 32 but the nextion still receives double digits.

when I send out json to the esp32 it does this:

{"sessionid":"0_4_1618493902","staarrttTT""::117755778844,,""eennddTT""::118855779977,,""ssttaarrttDD""::223344662222,,""eennddDD""::225500997722,,""aavvggHHRR""::00}}

so for 32 chars it works as expected and after that every character is doubled.

Tinus
Posts: 40
Joined: Sun Feb 14, 2021 4:53 pm

Re: UART not working with today's version of micropython

Post by Tinus » Thu Apr 15, 2021 2:02 pm

Changing the txbuf doesn't change the behaviour.

User avatar
Roberthh
Posts: 3667
Joined: Sat May 09, 2015 4:13 pm
Location: Rhineland, Europe

Re: UART not working with today's version of micropython

Post by Roberthh » Thu Apr 15, 2021 2:11 pm

I cannot replicate that behavior. I have set the UART to 9600 baud, txbuf to 32, and get the proper message, received by a USB/UART bridge:

{"sessionid":"0_4_1618493902","startT":175784,"endT":185797,"startD":234622,"endD":250972,"avgHR":0}

Which firmware version are you using? Type Ctrl-B to get it.

Edit: Looking at it with a logic analyzer shows not problems either.

User avatar
Roberthh
Posts: 3667
Joined: Sat May 09, 2015 4:13 pm
Location: Rhineland, Europe

Re: UART not working with today's version of micropython

Post by Roberthh » Thu Apr 15, 2021 2:21 pm

What happens if you set timeout_char=10?

Edit: What is the UART setting for writing to the nextion display?
Edit2: Do you use both UARTs at the same time?

Tinus
Posts: 40
Joined: Sun Feb 14, 2021 4:53 pm

Re: UART not working with today's version of micropython

Post by Tinus » Thu Apr 15, 2021 2:43 pm

Roberthh wrote:
Thu Apr 15, 2021 2:21 pm
What happens if you set timeout_char=10?

Edit: What is the UART setting for writing to the nextion display?
The same thing happens.

UART(1, baudrate=115200, bits=8, parity=None, stop=1, tx=4, rx=5, timeout=10, timeout_char=10, txbuf=32)

I am using this version today:
rp2-pico-20210415-unstable-v1.14-170-ga9bbf7083

(the ctrl-b thing doesn't work for me in thonny? )

Tinus
Posts: 40
Joined: Sun Feb 14, 2021 4:53 pm

Re: UART not working with today's version of micropython

Post by Tinus » Thu Apr 15, 2021 2:51 pm

Roberthh wrote:
Thu Apr 15, 2021 2:21 pm
Edit2: Do you use both UARTs at the same time?
Yes I do.

User avatar
Roberthh
Posts: 3667
Joined: Sat May 09, 2015 4:13 pm
Location: Rhineland, Europe

Re: UART not working with today's version of micropython

Post by Roberthh » Thu Apr 15, 2021 2:53 pm

Shouldn't it be:

UART(1, baudrate=115200, bits=8, parity=None, stop=1, tx=Pin(4), rx=Pin(5), timeout=10, timeout_char=10, txbuf=32)

Tinus
Posts: 40
Joined: Sun Feb 14, 2021 4:53 pm

Re: UART not working with today's version of micropython

Post by Tinus » Thu Apr 15, 2021 3:00 pm

Roberthh wrote:
Thu Apr 15, 2021 2:53 pm
Shouldn't it be:

UART(1, baudrate=115200, bits=8, parity=None, stop=1, tx=Pin(4), rx=Pin(5), timeout=10, timeout_char=10, txbuf=32)
Yes sorry, that is what happens, but it is constructed in different classes so I copy pasted some there (badly, apologies for that).

This is what it reports when I print(self.uart):

UART(1, baudrate=115200, bits=8, parity=None, stop=1, tx=4, rx=5, txbuf=32, rxbuf=256, timeout=10, timeout_char=10, invert=None)

User avatar
Roberthh
Posts: 3667
Joined: Sat May 09, 2015 4:13 pm
Location: Rhineland, Europe

Re: UART not working with today's version of micropython

Post by Roberthh » Thu Apr 15, 2021 3:05 pm

No worries. I just wanted to be sure. And the report of the UART setting could indeed reflect the way it is set.
But still I cannot replicate that, even if I send at two lines. Do you have the option to connect a logic analyzer, or just a UART/USB bridge to a PC for verification, that indeed double characters are sent.

Post Reply