The [UART](https://en.wikipedia.org/wiki/Universal_asynchronous_receiver/transmitter) (Universal asynchronous receiver/transmitter) module allows configuration of and communication over the UART serial port.
The default setup for the console uart is controlled by build-time settings. The default uart for console is `UART0`. The default rate is 115,200 bps. In addition, auto-baudrate detection is enabled for the first two minutes
after platform boot. This will cause a switch to the correct baud rate once a few characters are received. Auto-baudrate detection is disabled when `uart.setup` is called.
- event "data" has a callback like this: `function(data) end`
- event "error" has a callback like this: `function(err) end`. `err` could be one of "out_of_memory", "break", "rx_error".
-`run_input` 0 or 1. Only for "data" event on console uart. If 0, input from UART will not go into Lua interpreter, can accept binary data. If 1, input from UART will go into Lua interpreter, and run.
-`uart.MODE_UART` default UART mode, is set after uart.setup() call
-`uart.MODE_RS485_COLLISION_DETECT` receiver must be always enabled, transmitter is automatically switched using RTS pin, collision is detected by UART hardware (note: no event is generated on collision, limitation of esp-idf)
-`uart.MODE_RS485_APP_CONTROL` receiver/transmitter control is left to the application
-`uart.MODE_RS485_HALF_DUPLEX` receiver/transmitter are controlled by RTS pin
Wait for any data currently in the UART transmit buffers to be written out. It can be useful to call this immediately before a call to [`node.sleep()`](node.md#nodesleep) because otherwise data might not get written until after wakeup.
#### Syntax
`uart.txflush(id)`
#### Parameters
-`id` uart id
#### Returns
`nil`
#### Example
```lua
print("I want this to show up now not in 5 seconds")
Configure the light sleep wakeup threshold. This is the number of positive edges that must be seen on the UART RX pin before a light sleep wakeup will be triggered. The minimum value is 3. The default value is undefined, therefore you should always call this function before the first time you call `node.sleep()` with the uart option set.