Skip to main content


Sends one or more bytes to the serial port




Name Type Description
dataToWrite Integer, string or blob One or more values to write to serial port




This method writes bytes to the UART via a transmit (output) FIFO. It will block until all the supplied data has been transferred to the FIFO, but does not wait for the bytes to be transmitted. To wait until the FIFO has drained, ie. until all the data has been sent out on the wire, use uart.flush().

To prevent the call from blocking, configure the UART with the CALLBACK_WITH_FLAGS flag set and pass in a callback function with a single parameter. The argument passed into this parameter will contain a bitfield of event flags (see uart.configure()): check for the presence of the WRITE_HALF_DONE flag (ie. bit 7 set) and then write sufficient data to fill the remaining half of the FIFO. Repeat this process until all your data has been sent.

By default, the transmit FIFO is set at 80 bytes is size. However, under impOS™ Release 32 and up, the size of the FIFO may be altered using uart.settxfifosize().

Example Code

The following imp device code uses uart.write() — implemented as uart57 and aliased as arduino — to send an alternating signal onto the UART bus which the Arduino device (code below) reads and responds by flashing an LED and returning one of two set signal values.