UART

Sending and receiving data via UART.


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

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

// Check if there is content in the buffer
uart1.any()

// Read content from the buffer
uart1.read()

// Write content to UART
uart1.write('Hello')

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