Using UART on XIAO nrf52840 in MicroPython

Hi,

I’m trying to use the UART on a XIAO nrf52840 in MicroPython but I’m not getting any response.
So I’d like to troubleshoot the UART.

Say I use the most basic code:

from machine import UART

modem = UART(0, 115200)
modem.init()

How can I now check the defaults for bits/parity/stop/rx/tx ?

Also, is UART 0 reserved for the REPL? I’m using Thonny and I’m printing on USB, does that mean I can’t use UART 0?

Thanks!

Hi there.
So not being a Python guy, I do see this working, YMMV

import serial

ser = serial.Serial(
        port = '/dev/ttyUSB0',
        baudrate = 115200,
        timeout = 10,
        xonxoff = False
)
ser.reset_output_buffer()
ser.reset_input_buffer()
val = 0
command = ''
command = input("Enter command: ")
val = ser.write(command.encode(encoding = 'ascii', errors = 'strict'))
print("Waiting bytes: ", ser.in_waiting)
print("Bytes written: ", val)
in_data = ''
in_data = ser.read_until(b'}')
print(in_data)

HTH
GL :slight_smile: PJ :v:

Yah, thanks for your reply but it’s micropython, not python.
This topic can be closed, sorry

How did you bootload micropy i try and cant get it done?