MQTT data spec
This document describes the MQTT data model that's used to communicate with the Smart Sensor Mesh Network.
- Specification relies on the MQTT version 3.1 or higher.
Configuration
Topic: /sauter/viasens/<network-id>/<node-address>/configure
Smart Sensor Config Data JSON Model
Devices have several parameters that need to be configured based on their deployment environment. These settings are mainly for configuring devices' sensors, with some requiring basic options like Change-of-Value and period, while others, like the FIR sensor, need specialized parameters such as emissivity.
-
report-timeis the maximum time between the sending of 2 consecutive values -
dead-timeis the blocking time used to prevent sending value -
covis Change-of-Value; when specified change in sensor value is detected, current value is sent immediately, and bothreport-timeanddead-timecounters are reset -
temperature:sourceis a temperature source and it can be:FIR = 0-> default (Far Infrared, sensor that detects temperature by measuring the infrared radiation emitted by an object)NTC = 1(Negative Temperature Coefficient, thermistor that decreases in resistance as temperature increases)
emissivitydetermines how effectively a surface radiates infrared energy, which is important for FIR sensors; values are between 0 (low) and 100 (high/perfect)ntc-offsetis an adjustment to the temperature reading from an NTC thermistor sensor, helping to ensure accurate measurements
-
occupancy:hold-timeis defined as the time during which the occupancy state stays in its current state if no further movement/presence is detectedsensitivityis responsiveness of PIR sensor to movements and it can be:LOW = 0(detects slow movements, like walking)MEDIUM = 1-> defaultHIGH = 2(detects also fast and small movements)
modedefines the source of occupancy output and can be:PIR = 0-> default (Passive Infrared, sensor detects changes in infrared light levels in its field of view and triggers an alert or action when motion is detected)
dead-timeis internally set to 0 and it can't be configuredcovis triggered when state changes and it can't be configured as well
-
illuminance:- light sensor with a correction factor uses a linear equation to adjust its raw readings
- light correction factor follows an a*x+b curve.
slopeis defined by the a constant andinterceptby the b constant, while x is raw reading
-
microphone:ceiling-typeis used by the microphone algorithms to compensate the sound pressure level and it can be:OTHER = 0-> default
-
ibeacon:tx-poweris defined as an enumeration:-12 dBm = 0-9 dBm = 1-6 dBm = 2-3 dBm = 30 dBm = 4-> default+3 dBm = 5+6 dBm = 6+9 dBm = 7
Default values are provided in example.
{
"type": "sensors-config",
"payload": {
"temperature": {
"emissivity": "uint",
"source": "uint",
"ntc-offset": "float",
"cov": "float",
"report-time": "uint",
"dead-time": "uint"
},
"occupancy": {
"hold-time": "uint",
"sensitivity": "uint",
"mode": "uint"
},
"humid": {
"cov": "float",
"report-time": "uint",
"dead-time": "uint"
},
"voc": {
"cov": "float",
"report-time": "uint",
"dead-time": "uint"
},
"co2": {
"cov": "float",
"report-time": "uint",
"dead-time": "uint"
},
"illuminance": {
"slope": "float",
"intercept": "float",
"cov": "float",
"report-time": "uint",
"dead-time": "uint"
},
"microphone": {
"ceiling-type": "uint",
"cov": "float",
"report-time": "uint",
"dead-time": "uint"
},
"ibeacon": {
"tx-power": "uint"
}
}
}
Sensor Reporting and Dead Time Mechanism
Report Time Expiration and Data Transmission
- The system continuously monitors individual sensors.
- Upon expiration of the report time, the sensor's current reading is sent out.
- Report time counter reset: After transmission, the report time counter resets to zero.
- If report time = 0 : Values will not be sent periodically, only on COV changes (with respect to dead time)
Dead Time Considerations
- Definition: Dead time is an interval that is less than or equal to the report time, and is used to block sending upon COV
- Equal Dead and Report Time: If dead time equals report time, the reading is sent once at expiration. Both counters are then reset.
- Dead time > report time: Report time will be set to dead time value.
Handling Change of Value (COV) Checks
- When dead time < report time, the following process occurs:
- At dead time expiration: Perform a COV check.
- If COV detected: Send the current sensor value immediately, and reset both counters.
- If no COV: Perform COV checks until expiration of report time and if COV is detected before report time expires send value and reset both report and dead timer counters.
- Dead time = 0:
- Send value anytime COV occurs or upon report time expiration (if report time != 0)
- COV = 0:
- Block sending upon COV change, only send on expiration of report time (if report time != 0)
Control Payloads
Topic: /sauter/viasens/<network-id>/<node-address>/control
Two LED ring control payloads are used, led-ring and led-ring-basic. led-ring is a bit more complex and supports more animations, while led-ring-basic has simpler packet and supports less patterns.
LED Ring Data Specification
Type: led-ringmodedetermines the LED Ring animation;-1clears the LED Ringdurationdetermines the duration of animation in milliseconds (animation repetiton in a continuous loop isn't supported)speeddetermines speed of the animation; value range is0-255colorsare colour modifiers for the specific modes (note: values should be in hex format and inside of quotes, e.g. "0xFF0000"):-1: when clearing LED ring, colours don't matter0: only first colour from array is used1-3: first two colours from array are used4-102: all colours from array are used
mode can be one of the following values:
| Mode Identifier | Mode ID | Description |
|---|---|---|
| CLEAR_ANIMATION | -1 | Stops any ongoing LED animation |
| FX_MODE_STATIC | 0 | Static LED animation |
| FX_MODE_BLINK | 1 | Blinking LED animation |
| FX_MODE_BREATH | 2 | Breathing LED animation |
| FX_MODE_COLOUR_WIPE | 3 | Colour wipe LED animation |
| FX_MODE_COLOUR_WIPE_RANDOM | 4 | Random colour wipe LED animation |
| FX_MODE_RANDOM_COLOUR | 5 | Random colour LED animation |
| FX_MODE_COLOUR_SWEEP | 6 | Colour sweep LED animation |
| FX_MODE_DYNAMIC | 7 | Dynamic LED animation |
| FX_MODE_RAINBOW | 8 | Rainbow LED animation |
| FX_MODE_RAINBOW_CYCLE | 9 | Rainbow cycle LED animation |
| FX_MODE_SCAN | 10 | Scanning LED animation |
| FX_MODE_DUAL_SCAN | 11 | Dual scanning LED animation |
| FX_MODE_FADE | 12 | Fading LED animation |
| FX_MODE_THEATER_CHASE | 13 | Theater chase LED animation |
| FX_MODE_THEATER_CHASE_RAINBOW | 14 | Rainbow theater chase LED animation |
| FX_MODE_RUNNING_LIGHTS | 15 | Running lights LED animation |
| FX_MODE_SAW | 16 | Saw LED animation |
| FX_MODE_TWINKLE | 17 | Twinkling LED animation |
| FX_MODE_DISSOLVE | 18 | Dissolving LED animation |
| FX_MODE_DISSOLVE_RANDOM | 19 | Random dissolving LED animation |
| FX_MODE_SPARKLE | 20 | Sparkling LED animation |
| FX_MODE_FLASH_SPARKLE | 21 | Flash sparkling LED animation |
| FX_MODE_HYPER_SPARKLE | 22 | Hyper sparkling LED animation |
| FX_MODE_STROBE | 23 | Strobing LED animation |
| FX_MODE_STROBE_RAINBOW | 24 | Rainbow strobing LED animation |
| FX_MODE_MULTI_STROBE | 25 | Multi strobe LED animation |
| FX_MODE_BLINK_RAINBOW | 26 | Rainbow blinking LED animation |
| FX_MODE_ANDROID | 27 | Android LED animation |
| FX_MODE_CHASE_COLOUR | 28 | Colour chasing LED animation |
| FX_MODE_CHASE_RANDOM | 29 | Random chasing LED animation |
| FX_MODE_CHASE_RAINBOW | 30 | Rainbow chasing LED animation |
| FX_MODE_CHASE_FLASH | 31 | Flash chasing LED animation |
| FX_MODE_CHASE_FLASH_RANDOM | 32 | Random flash chasing LED animation |
| FX_MODE_CHASE_RAINBOW_WHITE | 33 | White rainbow chasing LED animation |
| FX_MODE_COLOURFUL | 34 | Colourful LED animation |
| FX_MODE_TRAFFIC_LIGHT | 35 | Traffic light LED animation |
| FX_MODE_COLOUR_SWEEP_RANDOM | 36 | Random colour sweep LED animation |
| FX_MODE_RUNNING_COLOUR | 37 | Running colour LED animation |
| FX_MODE_RUNNING_RED_BLUE | 38 | Running red-blue LED animation |
| FX_MODE_RUNNING_RANDOM | 39 | Random running LED animation |
| FX_MODE_LARSON_SCANNER | 40 | Larson scanner LED animation |
| FX_MODE_COMET | 41 | Comet LED animation |
| FX_MODE_FIREWORKS | 42 | Fireworks LED animation |
| FX_MODE_RAIN | 43 | Rain LED animation |
| FX_MODE_MERRY_CHRISTMAS | 44 | Merry Christmas LED animation |
| FX_MODE_FIRE_FLICKER | 45 | Fire flicker LED animation |
| FX_MODE_GRADIENT | 46 | Gradient LED animation |
| FX_MODE_LOADING | 47 | Loading LED animation |
| FX_MODE_POLICE | 48 | Police LED animation |
| FX_MODE_POLICE_ALL | 49 | All-police LED animation |
| FX_MODE_TWO_DOTS | 50 | Two dots LED animation |
| FX_MODE_TWO_AREAS | 51 | Two areas LED animation |
| FX_MODE_CIRCUS_COMBUSTUS | 52 | Circus combustus LED animation |
| FX_MODE_HALLOWEEN | 53 | Halloween LED animation |
| FX_MODE_TRICOLOUR_CHASE | 54 | Tricolour chasing LED animation |
| FX_MODE_TRICOLOUR_WIPE | 55 | Tricolour wipe LED animation |
| FX_MODE_TRICOLOUR_FADE | 56 | Tricolour fade LED animation |
| FX_MODE_LIGHTNING | 57 | Lightning LED animation |
| FX_MODE_ICU | 58 | ICU LED animation |
| FX_MODE_MULTI_COMET | 59 | Multi-comet LED animation |
| FX_MODE_DUAL_LARSON_SCANNER | 60 | Dual Larson scanner LED animation |
| FX_MODE_RANDOM_CHASE | 61 | Random chasing LED animation |
| FX_MODE_OSCILLATE | 62 | Oscillating LED animation |
| FX_MODE_PRIDE_2015 | 63 | Pride 2015 LED animation |
| FX_MODE_JUGGLE | 64 | Juggling LED animation |
| FX_MODE_PALETTE | 65 | Palette LED animation |
| FX_MODE_FIRE_2012 | 66 | Fire 2012 LED animation |
| FX_MODE_COLOURWAVES | 67 | Colour waves LED animation |
| FX_MODE_BPM | 68 | BPM LED animation |
| FX_MODE_FILLNOISE8 | 69 | Fill noise 8 LED animation |
| FX_MODE_NOISE16_1 | 70 | Noise 16_1 LED animation |
| FX_MODE_NOISE16_2 | 71 | Noise 16_2 LED animation |
| FX_MODE_NOISE16_3 | 72 | Noise 16_3 LED animation |
| FX_MODE_NOISE16_4 | 73 | Noise 16_4 LED animation |
| FX_MODE_COLOURTWINKLE | 74 | Colour twinkle LED animation |
| FX_MODE_LAKE | 75 | Lake LED animation |
| FX_MODE_METEOR | 76 | Meteor LED animation |
| FX_MODE_METEOR_SMOOTH | 77 | Smooth meteor LED animation |
| FX_MODE_RAILWAY | 78 | Railway LED animation |
| FX_MODE_RIPPLE | 79 | Ripple LED animation |
| FX_MODE_TWINKLEFOX | 80 | Twinkle fox LED animation |
| FX_MODE_TWINKLECAT | 81 | Twinkle cat LED animation |
| FX_MODE_HALLOWEEN_EYES | 82 | Halloween eyes LED animation |
| FX_MODE_STATIC_PATTERN | 83 | Static pattern LED animation |
| FX_MODE_TRI_STATIC_PATTERN | 84 | Tricolour static pattern LED animation |
| FX_MODE_SPOTS | 85 | Spots LED animation |
| FX_MODE_SPOTS_FADE | 86 | Fading spots LED animation |
| FX_MODE_GLITTER | 87 | Glitter LED animation |
| FX_MODE_CANDLE | 88 | Candle LED animation |
| FX_MODE_STARBURST | 89 | Starburst LED animation |
| FX_MODE_EXPLODING_FIREWORKS | 90 | Exploding fireworks LED animation |
| FX_MODE_BOUNCINGBALLS | 91 | Bouncing balls LED animation |
| FX_MODE_SINELON | 92 | Sinelon LED animation |
| FX_MODE_SINELON_DUAL | 93 | Dual sinelon LED animation |
| FX_MODE_SINELON_RAINBOW | 94 | Rainbow sinelon LED animation |
| FX_MODE_POPCORN | 95 | Popcorn LED animation |
| FX_MODE_DRIP | 96 | Drip LED animation |
| FX_MODE_PLASMA | 97 | Plasma LED animation |
| FX_MODE_PERCENT | 98 | Percentage LED animation |
| FX_MODE_RIPPLE_RAINBOW | 99 | Rainbow ripple LED animation |
| FX_MODE_HEARTBEAT | 100 | Heartbeat LED animation |
| FX_MODE_SUNRISE | 101 | Sunrise LED animation |
| FX_MODE_FLOW | 102 | Flow LED animation |
{
"mode": "int8",
"duration": "uint32 - [milliseconds]",
"speed": "uint8",
"colors": [
"string - hex colour, e.g. 0x112233 or #112233",
"string - hex colour, e.g. 0x112233 or #112233",
"string - hex colour, e.g. 0x112233 or #112233"
]
}
LED Ring Basic Data Specification
Type: led-ring-basicpatterndetermines the LED Ring Basic animation- up to 64 patterns supported
- pattern repeats itself indefinitely until it is cleared or another pattern replaces it
colorsis a two-element array containing 6-bit encoded colours (note: values should be in decimal format without quotes, e.g. [12, 48]):- up to 64 RGB colours are possible per value, each RGB channel being coded over 2 bits
- 6-bit encoding is used to optimize packet size
- e.g. green colour would be represented as
12(RGB = (0, 3, 0)), where red, green and blue are coded over 2-bits as00,11and00, so the 6-bit binary number is001100, which is12in decimal
periodrepresents duration of one pattern animation until it repeats itself. The value is expressed in multiples of 250 ms. Max is 255, 0 means statically on (the range of period duration is [0.25, 63.75] seconds).- examples:
- value 0x08 means 8 * 0.25 seconds = 2 seconds
- value 0x51 means 81 * 0.25 seconds = 20.25 seconds
- value 0xFF means 255 * 0.25 seconds = 63.75 seconds
- examples:
duty-cycleof the two-colour animation, if any. Percentages, in 10% increments (11 values).- examples:
- value 0 means 0%
- value 5 means 50% (50% of the time first colour will be active, 50% second)
- value 10 means 100%
- examples:
pattern can be one of the following values:
| Pattern | Value |
|---|---|
| Clear | 1 |
| Full | 2 |
| Half / Blinking | 3 |
| Half / Alternating | 4 |
| Quarter 1 - Blinking | 5 |
| Quarter 2 - Blinking | 6 |
| Quarter 3 - Blinking | 7 |
| Quarter 4 - Blinking | 8 |
| Quarter 1 - Alternating | 9 |
| Quarter 2 - Alternating | 10 |
| Quarter 3 - Alternating | 11 |
| Quarter 4 - Alternating | 12 |
| Six Opposite - Blinking | 13 |
| Six Opposite - Alternating | 14 |
| Twelve Opposite - Blinking | 15 |
| Twelve Opposite - Alternating | 16 |
| Spin clockwise | 17 |
| Spin counterclockwise | 18 |
Blinking refers to the colour type both colours displayed at the same time .
{
"pattern": "uint6",
"colors": [uint6 - 6-bit colour, uint6 - 6-bit colour],
"period": "uint8 - value expressed in multiples of 250 ms",
"duty-cycle": "uint4 - percentages in increments of 10%"
}
Sensor Values
Topic: /sauter/viasens/<network-id>/<node-address>
Smart Sensor Data JSON Model
typespecifies the data type, e.g. Humid data, FIR data, etc.payloadholds type-specific payloads - encapsulates the context of the Type Specific Payloads and prevents possible key collisions
{
"type": "string",
"payload": {
"Type-Specific Payloads - check the spec below"
}
}
Type-Specific Payloads Specification
| Type | Description |
|---|---|
temperature | |
voc | |
co2 | |
humid | |
illuminance | |
microphone | |
motion | |
health | |
led-ring | |
led-ring-basic |
Sensor Payloads
Temperature Data Specification (Type: temperature)
{
"temperature": "float - [°C]"
}
VOC Data Specification (Type: voc)
{
"voc": "int32 - [VOC Index]"
}
CO2 Data Specification (Type: co2)
{
"co2": "uint16 - [ppm]"
}
Humidity Data Specification (Type: humid)
{
"humidity": "uint8 - [%rH]"
}
Illuminance Data Specification (Type: illuminance)
{
"illuminance": "uint16 - [lux]"
}
Microphone Data Specification (Type: microphone)
{
"noise-level": "uint8 - [dB]"
}
Motion Data (Type: motion)
{
"occupancy": "1 or 4 - [Vacant / No movement, Occupied / Movement]"
}
Health Data Specification (Type: health)
Note 1: Health payload is a byte or more precisely a bitmask with each bit indicating validity of individual sensor's output. Bit value 0 means the sensor is missing or faulty and bit value 1 indicates the sensor is present and working. The states of the following sensors are present in the payload:
- bit7 - temperature NTC
- bit6 - temperature FIR
- bit5 - humidity
- bit4 - VOC
- bit3 - illuminance
- bit2 - noise level
- bit1 - occupancy
- bit0 - CO2
{
"health": "uint8"
}
Example MQTT Packets
Configuration Packet
Example of configuration packet with default values sent by the third-party to the gateway in order to configure node with the address 5.
- Client posts to topic `/sauter/viasens/<network-id>/5/configure` in order to configure the node `5`
{
"type": "sensors-config",
"payload": {
"temperature": {
"emissivity": 90,
"source": 0,
"ntc-offset": 0.0,
"cov": 0.2,
"report-time": 900,
"dead-time": 300
},
"occupancy": {
"hold-time": 30,
"sensitivity": 2,
"mode": 0,
},
"humid": {
"cov": 5,
"report-time": 900,
"dead-time": 300
},
"voc": {
"cov": 30,
"report-time": 900,
"dead-time": 300
},
"co2": {
"cov": 50,
"report-time": 900,
"dead-time": 300
},
"illuminance": {
"slope": 1,
"intercept": 0,
"cov": 50,
"report-time": 900,
"dead-time": 300
},
"microphone": {
"ceiling-type": 0,
"cov": 5,
"report-time": 900,
"dead-time": 300
},
"ibeacon": {
"tx-power": 4
}
}
}
LED Ring Control Packet
Example of the full packet sent by the third-party to the gateway in order to control the LED Ring on the node with the address 5.
The packet will set the LED Ring into mode 1 with the speed modifier of 100, colours modifiers are set to blue, green and red in hex, and the animation will be on for 10 seconds (10000 ms).
- Client posts to topic `/sauter/viasens/<network-id>/5/control` in order to control the LED Ring of the node `5`
{
"type": "led-ring",
"payload": {
"mode": 1,
"duration": 10000,
"speed": 100,
"colors": [
"0x0000FF",
"0x00FF00",
"0xFF0000"
]
}
}
LED Ring Basic Control Packet
Example of the full packet sent by the third-party to the gateway in order to control the LED Ring on the node with the address 5.
The packet will set the LED Ring into pattern 4 with the period of 20 (5s), colours modifiers are set to red and green in decimal (each RGB channel being coded over 2 bits), and with the duty cycle set to 5 (50%).
- Client posts to topic `/sauter/viasens/<network-id>/5/control` in order to control the LED Ring of the node `5`
{
"type": "led-ring-basic",
"payload": {
"pattern": 4,
"colors": [12, 48],
"period": 20,
"duty-cycle": 5
}
}
Humidity Packet
Example of the full packet sent by the gateway to the MQTT broker, packet represents sensor reading of 49%rH, and is generated by the node with the address 5.
- Gateway posts to topic `/sauter/viasens/<network-id>/5` packet received by the node `5`
{
"type": "humid",
"payload": {
"humidity": 49
}
}