Page 1 of 1

Configuring baud rate of UART

Posted: Thu Jul 22, 2021 8:02 pm
by Yadnik
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!!

Re: Configuring baud rate of UART

Posted: Thu Jul 22, 2021 11:04 pm
by williamhenrick
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

Re: Configuring baud rate of UART

Posted: Fri Jul 23, 2021 5:42 am
by Yadnik
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.