This sensor type allows you to easily process data from an external MCU like Arduino and send to a coordinator or vice versa. Apart from the regular UART channel, this sensor does not require additional data processing on the coordinator side.

Note: this feature is not available in the router firmware for CC253x.

UART sensors
UART sensors

How to configure the firmware

  1. Firstly, you should configure an UART connection with your MCU (baud rate, parity, and number of stop bits). It should be configured before all UART sensors. This feature is incompatible with other UART-based sensors like MHZ19, Senseair S8 or MODBUS.
  2. Add one or more UART sensors with the necessary subtype.

The figure above shows an example of four UART sensors.

UART sensor subtypes

On/Off – implements a simple binary sensor with two states: On or Off. It looks like a contact sensor if access rights are “Reportable” or “Read”, and as a switch in other cases.

Analog value – any generic analog value with a single precision float data type (32 bits). Additionally, you can define units for this analog value.

Level control – implements a virtual level control with values from 0 to 255.

Button clicks – allows you to send button clicks (single, double, triple, hold, release) to a coordinator (it always has “reportable” access rights).

Access rights

Reportable – the firmware can send a value to a coordinator. The coordinator cannot request a value or write to it.
Read – reportable + the coordinator can initiate reading of the value at any time.
Write – reportable + the coordinator write a value to the sensor.
Read/Write – all access rights.

UART command format

The firmware supports a special command format optimized for fast data transfer and processing.

You can download the ready-to-use library and examples for Arduino IDE here. Your comments, examples, and improvements are welcome!


<STX> – single ASCII character with code 0x21 (!).

<ETX> – single ASCII character with code 0x3B (;).

<ID> – endpoint number and data type encoded in a single byte:
Bits [3:0] – endpoint number minus 1 (0 – 15). It should match the endpoint number in the device configuration. For the figure above, the configuration defines endpoints 2-5 for UART sensors, that should be encoded as 1-4 in a data packet.
Bits [7:4] – data type.
0 – Boolean value encoded as one byte. It can contain 0 (off) or 1 (on) only. Generally, it is used for the “On/Off” sensor.
1 – (UINT8) Unsigned decimal in one byte. Mainly, it is used for the “Level control” or “Button clicks” sensor.
9 – (FLOAT) Single precision value encoded in four bytes (IEEE-754, LSB first). Mainly, it is used for the “Analog value” sensor.
0xE – endpoint command, the command code is encoded as a single byte in <DATA>
0xF – system-wide command.

<DATA> – several data bytes depending on the data type.

<CRC> – checksum for all bytes from <STX> to <ETX>. It is a simple LSB of an arithmetic sum of all bytes. Encoded as a single byte.

Escaping of <STX> and <ETX> bytes in a data packet

It is used to encode and eliminate starting and ending signatures that may appear in <ID> or <DATA> and provide robust data processing.
<STX> – encoded as two bytes 0xDB 0xDC.
<ETX> – 0xDB 0xDD.
0xDB is encoded 0xDB 0xDE.

Note: Checksum is being calculated after escaping bytes.


1 – “Get values” endpoint command (firmware > external MCU) before sending a periodic report and waits for a response for 500 ms.
2 – System-wide command (external MCU > firmware) to initiate rejoining process. The firmware sends an echo as an acknowledgement to this command.
3 – “Send periodic reports” system-wide command (external MCU > firmware) to send a periodic report for all endpoints.
0xE0 – 0xEF the firmware sends a network status to the external MCU.

0xE0 – Initialized – not started automatically.
0xE1 I- Initialized – not connected to anything.
0xE2 – Discovering PAN’s to join.
0xE3 – Joining a PAN.
0xE4 – Re-joining a PAN in secure mode scanning in current channel, only for end devices.
0xE5 – Joined but not yet authenticated by trust center.
0xE6 – Device joined, authenticated and is an end-device.
0xE7 – Device joined, authenticated and is a router.
0xEA – Device has lost information about its parent.
0xEB – Device is sending a Keep-Alive message to its parent.
0xEC – Device is waiting before trying to rejoin.
0xED – Re-joining a PAN in secure mode scanning in all channels, only for end devices.
0xEE – Re-joining a PAN in Trust center mode scanning in current channel, only for end devices.
0xEF – Re-joining a PAN in Trust center mode scanning in all channels, only for end devices.


Endpoint #3, On state: <STX> 0x12 0x01 <ETX> 0x6F
Endpoint #3, Off state: <STX> 0x12 0x00 <ETX> 0x6E

Endpoint #4, analog value “0.0”: <STX> 0x93 0x00 0x00 0x00 0x00 <ETX> 0xEF
Endpoint #4, analog value “9999.0”: <STX> 0x93 0x00 0x3C 0x1C 0xC6 <ETX> 0x0D

Endpoint #6, single click: <STX> 0x15 0x01 <ETX> 0x72
Endpoint #6, double click: <STX> 0x15 0x02 <ETX> 0x73
Endpoint #6, triple click: <STX> 0x15 0x03 <ETX> 0x74
Endpoint #6, hold <STX> 0x15 0x04 <ETX> 0x75
Endpoint #6, release: <STX> 0x15 0x00 <ETX> 0x71

There are no comments.

Leave a Reply