UART - Send and Receive

Materials

  • AmebaD [ AMB23 / AMB21 / AMB22 / BW16 / BW16-TypeC ] x 1
  • USB to TTL Adapter x 1

Example

UART is a very versatile communication protocol and almost an essential part of a microcontroller. A TTL USB to Serial module is an IC that helps to translate UART signal to USB signal so that we can see uart log printed on our PC. This module is often found on many development boards, including ameba. However, the module on Ameba is reserved for LOG UART and Firmware uploading, that is why we need a separate module to communicate between ameba and PC.

AMB21/AMB22

There are 2 sets of UART available to Micropython users.

Unit TX RX
PA_21
PA_22
3
PA_26
PA_25

AMB23

There are 2 sets of UART available to Micropython users.

Unit TX RX
1
PB_1
PB_2
2
PA_21
PA_22

BW16/BW16-TypeC

There are 1 set of UART available to Micropython users.

Unit TX RX
PB_1
PB_2

Code

Copy and execute each line one by one to see its effect.

from machine import UART
uart = UART(tx="PB_1", rx= "PB_2")
uart.write('hello')
uart.write('123')
uart.read(5)
Please confirm that QQ communication software is installed