Configuring baud rate of UART

Discussion about programs, libraries and tools that work with MicroPython. Mostly these are provided by a third party.
Target audience: All users and developers of MicroPython.
Post Reply
Yadnik
Posts: 65
Joined: Thu May 13, 2021 6:01 am

Configuring baud rate of UART

Post by Yadnik » Thu Jul 22, 2021 8:02 pm

I am trying to display NMEA data like $GPGGA using uart.write(),using the zephyr port of MicroPython. The GPS by default runs on a baud rate of 9600 and my boards baud rate has been configured to 115200, due to which I feel the data cant be displayed and uart.write('$GPGGA') just prints out the $GPGGA6.I cannot use uart.init() as well to initialise baud rate.
As a last resort will I have to manually change the baud rate of gps module to 115200 using U-Centre application?
Can someone please guide me.Thank you very much!!

williamhenrick
Posts: 16
Joined: Wed Jul 14, 2021 8:58 am

Re: Configuring baud rate of UART

Post by williamhenrick » Thu Jul 22, 2021 11:04 pm

Yadnik wrote:
Thu Jul 22, 2021 8:02 pm
I cannot use uart.init() as well to initialise baud rate.
Why you can't use uart.init() ??

Code: Select all

from pyb import UART

uart = UART(1, 9600)                         # init with given baudrate
uart.init(9600, bits=8, parity=None, stop=1) # init with given parameters

Yadnik
Posts: 65
Joined: Thu May 13, 2021 6:01 am

Re: Configuring baud rate of UART

Post by Yadnik » Fri Jul 23, 2021 5:42 am

I think because I am using the Zephyr port of MicroPython https://github.com/micropython/micropyt ... /README.md and not on the dedicated MicroPython firmware I am not able to initialise baud rate of uart using uart.init().
The code I am writing is as follows:
>>> from machine import UART
>>>uart=UART("UART_0")
>>>uart.init(9600, bits=8, parity=None, stop=1)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
AttributeError: 'UART' object has no attribute 'init'

It would be very helpful if someone can please guide me with this.

Post Reply