UART
API Documents
Constructors
unit
: The unit ID, either 0 or 3baudrate
: 115200 is the recommended baudrate on amebadatabits
: the number of bits for data bits, usually 7 or 8 bitsstopbits
: the number of stop bits, usually 1 or 1.5 or 2 bitsparitybit
: for parity check, usually none, odd or eventimeout
: how long uart wait before its timeout (in milliseconds)tx_pin
: the transmitter pin, connect the rx pin of the receiverrx_pin
: the receiver pin, connect to tx pin of the transmitter
Note
Not all parameters are required, thus MicroPython will assume its default value once left blank, here are the default values for each optional parameter:
Parameter |
Default Value |
---|---|
Unit |
0 |
Baudrate |
115200 |
Databits |
8 |
Stopbits |
1 |
Paritybit |
0 |
Timeout |
10 (ms) |
Methods
length: the length of the data to receive
buffer: data buffer that can be a string, an integer or other data types
Check the status of uart irq when NOT passing any argument, and it will return True if irq is enabled, False if disabled
Enable/disable uart irq handler by passing True or False as bool
function: a function defined in python or a lambda function