To send data via a started UART, use the uart.send() method.
// Javascript Example
const uart = obniz.getFreeUart();
uart.start({tx: 0, rx: 1, baud: 9600 });
uart.send("Hello");
uart.send([0x00, 0x01, 0x02]);
The uart.send() method does not wait for the transmission to complete (non-blocking). Additionally, since UART does not verify whether the receiver has actually received the data, no error will occur even if the communication partner is not connected.
DE (Driver Enable)
When using UART for RS422 or RS485 communication, you can automatically manage the DE (Driver Enable) pin, which indicates the transmission state.
For example, if the DE pin of an external transceiver is connected to IO2, you can specify it as follows:
uart.setDE(2);
Once specified, the DE pin will be automatically toggled high/low before and after data is transmitted via the send() function.
// Javascript Example
const uart = obniz.getFreeUart();
uart.start({tx: 0, rx: 1, baud: 9600 });
uart.setDE(2);
uart.send("Hello");
uart.send([0x00, 0x01, 0x02]);