This example uses Adafruit’s busio package to create a UART object. It will read 3 characters from the FTDI cable which CoolTerm (Windows) or other terminal emulator is connected to.  The script then sends ‘hello world’ to the FTDI cable which will display in the terminal.

import board
import busio

uart = busio.UART(board.TX, board.RX, 115200, 8, None, 1, 1000)
data = uart.read(3)
# convert bytearray to string
data_string = ''.join([chr(b) for b in data])
print(data_string, end="")
uart.write('hello world')
uart.deinit()

This guide was first published on Dec 18, 2019. It was last updated on Dec 18, 2019.

This page (Example Code) was last updated on Dec 10, 2019.

Text editor powered by tinymce.