IoT Protocol

A sketch for a simple IoT protocol for typical star network topology.

A lot of inspiration is taken from

But the way actuators are handled are quite strange.

However there are a smartSleep() function that handles receive of messages on heartbeats.

Each sleep function has a "smart" variant, which sends heartbeat and process incoming messages before going to sleep. This is useful for sending out firmwares or commands for sleeping nodes. The controller must support buffering of messages and send them when node wakes up.

I think this is the way to go to always allow the sensor initiate communication.


The architecture should be suitable for a star network configuration with one or several (redundant) gateways to many sensors and/or actuators.

Data Model

Data Format

Data is represented as simple key/value pairs.

The key is a string.

The value is one of the supported data types.

Data can represented as:

Each data format (sensor data or configuration) has a unique identifiers which mandates its format.

The following types should be supported:

All formats have an empty value which means that is not entered e.g. 255 for uint8. This permit that only some values are updated in a message. For datatypes with variable length these can be very short.

A data format is specified as follows:

A generic parser can be used to translate between string and binary representation from the spec.

binary = to_binary(format, keys, values)
keys, values = from_binary(format, binary)
string = to_string(format, keys, values)

Radio message format (sensor/gateway)

Messaging over radio has the following format

Following parts may be encrypted with pre-shared node key.

Values are MSB (most significant byte/bit first)

The same format is used both for upstream and downstream messages.

Encryption may be supported using a device unique key installed at factory.

Message types

Attach a new sensor to network

Get sensor configuration

Upload sensor data to controller

Data format may be empty (i.e. heartbeat) and contain no information.

Typical Sensor Data (owned by sensor)

Typical Sensor Configuration (owned by controller)

Design Criteria's



Build a simulator to evaluate the system before implemented in hardware.

IoT Gateway


Gateway -> Device

Device -> Gateway

Controller -> Gateway

Attach device


Data Formats




Tags: MQTT, Gateway