Skip to content

MQTT Communication

Description

This page explains the way configuration data and sensor values are exchanged between the BrioSens device and the Cloud. All communication is done with the MQTT messaging protocol.

Acquisition script

There is a default Python script located under /usr/local/sbin/mqttClient.py. This script autorun as a system service under systemd. You can easily start, stop or restart this service named mqttClient using systemctl command (e.g. systemctl restart mqttClient). The script is using the dashboard configuration (via http://192.168.43.1). To enable communication with https://briosphere.io, please contact us.

Sequence of operation

The BrioSens will automatically connect to the MQTT broker. Once connected, the device will expect to receive a configuration on the /cfg topic for all its onboard IOs and sensors. Once all inputs are configured, the device will enter in a monitoring loop (if needed):

For digital ADC inputs:

  • When a threshold is exceeded, the device will send a message specifying the new value.
  • When a timer elapses, the device will send a message specifying the new value.

For digital IOs:

  • When a threshold is exceeded, the device will send a message specifying the new value.
  • When a timer elapses, the device will send a message specifying the new value.
  • For an output, the device will apply the changes coming from the MQTT broker.

Implementation Details

Configuration

Summary

Get configuration from the Cloud.

Topic

To get the configuration from the Cloud, use the following topic structure:

  • bw / SN / cfg

Where:

  • SN is the device serial number
Payload
Global - Configuration
Name Note Key Example
Sampling Rate The sampling rate of all acquisitions, value in ms. Note: Minimum recommanded delay between samples is 1000 mSec. sr "sr":1000
ADC - Configuration
Name Note Key Example
Enable 0: Disabled
1: Enabled
en "en":1
Current loop enable 0: Disabled
1: Enabled
cl "cl":1
Maximum voltage Value in mV mv "mv":24000
Time lapse in mSec tl "tl":100000
Trigger Value (vl):
current loop 0, in mV
current loop 1, in uA

Condition (cd):
0: Upper than
1: Lower than
2: Cross
tg "tg":[{"vl": 1800, "cd": 1}, {"vl": 12000, "cd": 0}]
I/O - Configuration
Name Note Key Example
Enable 0: Disabled
1: Enabled
en "en":1
Mode 0: Input
1: Output

Note: Output mode not available until HW130
md "md":0
Output value If output mode is selected

0: Low level
1: High level
vl "vl":0
Time lapse If input mode is selected

in mSec
tl "tl":2000
Trigger If input mode is selected

0: No trigger
1: Rising edge
2: Falling edge
3: Both
tg "tg":2
Temperature - Configuration
Name Note Key Example
Enable 0: Disabled
1: Enabled
en "en":1
Time lapse in mSec tl "tl":300000
Trigger Value (vl) in °mC

Condition (cd):

0: Upper than
1: Lower than
2: Cross
tg "tg":[{"vl": 12500, "cd": 0}, {"vl": 8000, "cd": 1}]
Humidity - Configuration
Name Note Key Example
Enable 0: Disabled
1: Enabled
en "en":1
Time lapse in mSec tl "tl":60000
Trigger Value (vl) in °m%

Condition (cd):

0: Upper than
1: Lower than
2: Cross
tg "tg":[{"vl": 60000, "cd": 0}, {"vl": 30000, "cd": 1}]
Example
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
{
  "sr": 1000,
  "adc": [
      {
          "en": 0
      },
      {
          "en": 1,
          "cl": 0,
          "mv": 24000,
          "tl": 5000,
          "tg": [
              {
                  "vl": 1800,
                  "cd": 1
              },
              {
                  "vl": 12000,
                  "cd": 0
              }
          ]
      },
      {
          "en": 0
      },
      {
          "en": 0
      }
  ],
  "io": [
      {
          "en": 0
      },
      {
          "en": 1,
          "md": 0,
          "tl": 30000,
          "tg": 1
      },
      {
          "en": 1,
          "md": 1,
          "vl": 1
      },
      {
          "en": 0
      }
  ],
  "temp": [
      {
          "en": 1,
          "tl": 60000,
          "tg": [
              {
                  "vl": 12500,
                  "cd": 0
              },
              {
                  "vl": 8000,
                  "cd": 1
              }
          ]
      }
  ],
  "rh": [
      {
          "en": 1,
          "tl": 60000
      }
  ]
}

ADC or analog sensor - Value change notification

Summary

Send new ADC or analog sensor value from the BrioSens to the Cloud.

Topic

Report an ADC input value with the following topic structure:

  • bw / SN / adc / ID

Where:

  • SN is the device serial number
  • ID is the ADC unique identifier
Payload
Name Description Required
Mode 0: 0-24 V
1: 4-20 mA
Yes
Value If mode is 0, value in uA
If mode is 1, value in mV
Yes
Reason 0: Timelapse
1: Trigger 1
n: Trigger n
Yes
Example

0,12500,1

DIN - Value change notification

Summary

Send new DIN value from the BrioSens to the Cloud.

Topic

Report a DIN value with the following topic structure:

  • bw / SN / io / ID

Where:

  • SN is the device serial number
  • ID is the DIN unique identifier
Payload
Name Description Required
Value 0 for a low level
1 for a high level
Yes
Reason 0: Timelapse
1: Trigger 1
n: Trigger n
Yes
Example

1,0