UART

Send and receive data via UART.


//Create a serial port instance
uart1 = machine.UART(1, tx=1, rx=3)

//Initialize the serial port
uart1.init(115200, bits=8, parity=None, stop=1)

//Is there any content in the cache?
uart1.any()

//Read the content in the buffer area
uart1.read()

//Write content to the serial port
uart1.write('Hello')

//Read/write case
while True:
    if uart1.any():
        print(uart1.read())
        uart1.write('Hello')
On This Page