septembre 24, 2020 | Modbus mapping - Sensing-Labs SLGateway | ||||||||||||||||||||||
|
Example | Device
index = 12 (SLGateway GUI→ APIs → Modbus) = 0x0C Device is a SenlabT We want to get the last measure (temperature in degC ) and it timestamp |
|||||||||||||||||||||
Function code to use : | 0x04 | Resource documentation HERE | |||||||||||||||||||||
Address to get last temperature measure : | 0x0C46 and
0x0C47 (two 16-bits registers) |
||||||||||||||||||||||
Address to get the timestamp of the last measures : | 0x0C42 to
0x0C45 (four 16-bits registers) |
Useful links (for dev): | |||||||||||||||||||||
How to convert measure (log value) ? | 0x41c10000 ==>
24.125degC HEX ===> IEEE754 32bits float Big Endian (ABCD) |
Online Hex to IEEE754 float conv. HERE | |||||||||||||||||||||
How to convert timestamp ? | 0x0000016AA1CD9B78 ==> 1557492767608 ===> Fri,10 May 2019 13:39:19 GMT HEX ==> decimal ==> human time |
Online Epoch&Unix Time conv. HERE | |||||||||||||||||||||
Slave address | 1 | ||||||||||||||||||||||
Port | 502 | ||||||||||||||||||||||
Modbus Mode | TCP/IP | ||||||||||||||||||||||
COMMON static (SLGateway) | |||||||||||||||||||||||
Information | Access | Function Code(s) |
Start Address (HEX) YY = device index |
Size | Data type | Units | Comment | ||||||||||||||||
SLGateway appEUI | Read | 04 | 0001 | 4 | HEX (8B) | none | 4 HEX words (ex : 0x70b3d580a0000000) |
||||||||||||||||
SLGateway version | Read | 04 | 0005 | 1 | HEX (2B) | none | Major.minor (ex: 0x0204) | ||||||||||||||||
SLGateway current time | Read/write | 03, 16 | 0000 | 4 | UINT_64 | ms | Timestamp (ms) Can be write since version 2.4.0 |
||||||||||||||||
Number of devices | Read | 04 | 0000 | 1 | UINT_16 | none | - | ||||||||||||||||
List of devices | Read | 02 | 0001 | 1...255 | BOOL | none | 1 if device declared 0 if not declared position is the device number |
||||||||||||||||
COMMON dynamic (all devices) | |||||||||||||||||||||||
Device EUI (devEUI) | Read | 04 | YY00 | 4 | HEX (8B) | none | 4 HEX words | ||||||||||||||||
Device Firrware version | Read | 03 | YY00 | 1 | HEX (2B) | none | Major.minor (ex: 0x0103) | ||||||||||||||||
Application ID | Read | 03 | YY01 | 4 | ASCII (8B) | none | UTF-8 (ex : SenlabM) | ||||||||||||||||
deviceActivation | Read | 02 | YY01 | 1 | BOOL | none | 1 if device connected | ||||||||||||||||
Battery level | Read | 04 | YY24 | 1 | UINT_16 | % | 0xFFFF if no value | ||||||||||||||||
RSSI level | Read | 04 | YY25 | 1 | INT_16 | dBm | 0x7FFF if no value | ||||||||||||||||
SNR level | Read | 04 | YY26 | 1 | INT_16 | dBm | 0x7FFF if no value | ||||||||||||||||
SenlabT | |||||||||||||||||||||||
Log number | Read | 04 | YY40 | 1 | UINT_16 | none | Nb max = 24 (measure is valid only when log number > 0) |
||||||||||||||||
Log period | Read | 04 | YY41 | 1 | UINT_16 | Minute | - | ||||||||||||||||
Last log Timestamp | Read | 04 | YY42 | 4 | UINT_64 | ms | Timestamp (ms) | ||||||||||||||||
Temperature Log values (first value is the last log) |
Read | 04 | YY46 (first) YY48 (2nd) ... YY74 (max) |
2..2*24 | FLOAT_32 | Ceclius degrees |
1 to 24 values with size 2 each 0x7FFFFFFF if no value Important : only last value(s) are available (no history) |
||||||||||||||||
Temperature2 Log values (first value is the last log) |
Read | 04 | YY76 (first) YY78 (2nd) ... YYA4 (max) |
2..2*24 | FLOAT_32 | Ceclius degrees |
1 to 24 values with size 2 each 0x7FFFFFFF if no value Important : only last value(s) are available (no history) |
||||||||||||||||
SenlabM (only "basic" and "datalog" modes) |
|||||||||||||||||||||||
Log number | Read | 04 | YY40 | 1 | UINT_16 | none | Nb max = 24 (measure is valid only when log number > 0) |
||||||||||||||||
Log period | Read | 04 | YY41 | 1 | UINT_16 | Minute | - | ||||||||||||||||
Last log Timestamp | Read | 04 | YY42 | 4 | UINT_64 | ms | Timestamp (ms) | ||||||||||||||||
raw_index Log values (first value is the last log) |
Read | 04 | YY46 (first) YY48 (2nd) ... YY74 (max) |
2..2*24 | UINT_32 | Pulse number | 1 to 24 values with size 2 each 0x7FFFFFFF if no value Important : only last value(s) are available (no history) |
||||||||||||||||
Wirecut | Read | 04 | YY76 | 1 | UINT_16 | none | Wirecut detection status (if activated) |
||||||||||||||||
Max interPulse | Read | 04 | YY77 | 2 | FLOAT_32 | 100 ms | Maximum duration between 2 pulse detection since the last
transmission (if activated) |
||||||||||||||||
raw_index2 Log values (first value is the last log) |
Read | 04 | YY78 (first) YY7A (2nd) ... YYA6 (max) |
2..2*24 | UINT_32 | Pulse number | 1 to 24 values with size 2 each 0x7FFFFFFF if no value Important : only last value(s) are available (no history) |
||||||||||||||||
SenlabH | |||||||||||||||||||||||
Log number | Read | 04 | YY40 | 1 | UINT_16 | none | Nb max = 24 (measure is valid only when log number > 0) |
||||||||||||||||
Log period | Read | 04 | YY41 | 1 | UINT_16 | Minute | - | ||||||||||||||||
Last log Timestamp | Read | 04 | YY42 | 4 | UINT_64 | ms | Timestamp (ms) | ||||||||||||||||
Temperature log values (first value is the last log) |
Read | 04 | YY46 (first) YY48 (2nd) ... YY74 (max) |
2..2*24 | FLOAT_32 | Ceclius degrees |
1 to 24 values with size 2 each 0x7FFFFFFF if no value Important : only last value(s) are available (no history) |
||||||||||||||||
Humidity log values (first value is the last log) |
Read | 04 | YY76 (first) YY77 (2nd) ... YY8D (max) |
1..24 | INT_16 | % | 1 to 24 values Important : only last value(s) are available (no history) |
||||||||||||||||
SenlabA (4-20mA) | |||||||||||||||||||||||
Log number | Read | 04 | YY40 | 1 | UINT_16 | none | Nb max = 24 (measure is valid only when log number > 0) |
||||||||||||||||
Log period | Read | 04 | YY41 | 1 | UINT_16 | Minute | - | ||||||||||||||||
Last log Timestamp | Read | 04 | YY42 | 4 | UINT_64 | ms | Timestamp (ms) | ||||||||||||||||
Log values (first value is the last log) |
Read | 04 | YY46 (first) YY48 (2nd) ... YY74 (max) |
2..2*24 | FLOAT_32 | mA | 1 to 24 values with size 2 each 0x7FFFFFFF if no value Important : only last value(s) are available (no history) |
||||||||||||||||
SenlabD | |||||||||||||||||||||||
state Timestamp | Read | 04 | YY42 | 4 | UINT_64 | ms | Timestamp (ms) | ||||||||||||||||
State value | Read | 04 | YY46 | 2 | UINT_32 | none | 0x7FFFFFFF if no value 00000000 if digital state is closed 00000001 if digital state is opened |
||||||||||||||||
SenlabP (since version 2.4.2) |
|||||||||||||||||||||||
Log number | Read | 04 | YY40 | 1 | UINT_16 | none | Nb max = 24 (measure is valid only when log number > 0) |
||||||||||||||||
Log period | Read | 04 | YY41 | 1 | UINT_16 | Minute | - | ||||||||||||||||
Last log Timestamp | Read | 04 | YY42 | 4 | UINT_64 | ms | Timestamp (ms) | ||||||||||||||||
Log values (first value is the last log) |
Read | 04 | YY46 (first) YY48 (2nd) ... YY74 (max) |
2..2*24 | UINT_32 | Number of detection | 1 to 24 values with size 2 each 0x7FFFFFFF if no value Important : only last value(s) are available (no history) |
||||||||||||||||
SenlabO (since version 2.5.0) |
|||||||||||||||||||||||
Log number | Read | 04 | YY40 | 1 | UINT_16 | none | Nb max = 12 (measure is valid only when log number > 0) |
||||||||||||||||
Log period | Read | 04 | YY41 | 1 | UINT_16 | Minute | - | ||||||||||||||||
Last log Timestamp | Read | 04 | YY42 | 4 | UINT_64 | ms | Timestamp (ms) | ||||||||||||||||
Temperature log values (first value is the last log) |
Read | 04 | YY46 (first) YY48 (2nd) ... YY5C (max) |
2..2*12 | FLOAT_32 | Ceclius degrees |
1 to 12 values with size 2 each 0x7FFFFFFF if no value Important : only last value(s) are available (no history) |
||||||||||||||||
Luminosity log values (first value is the last log) |
Read | 04 | YY5E (first) YY60 (2nd) ... YY74 (max) |
2..2*12 | UINT_32 | Lux | 1 to 12 values with size 2 each 0x7FFFFFFF if no value Important : only last value(s) are available (no history) |
||||||||||||||||
Humidity log values (first value is the last log) |
Read | 04 | YY76 (first) YY77 (2nd) ... YY81 (max) |
1..12 | INT_16 | % | 1 to 12 values Important : only last value(s) are available (no history) |
||||||||||||||||
Presence log values (first value is the last log) |
Read | 04 | YY82 (first) YY83 (2nd) ... YY8D (max) |
1..12 | INT_16 | none | 1 to 12 values Important : only last value(s) are available (no history) |
||||||||||||||||
Ratio log values (first value is the last log) |
Read | 04 | YY8E (first) YY90 (2nd) ... YYA4 (max) |
2..2*12 | UINT_32 | none | 1 to 12 values Important : only last value(s) are available (no history) |
||||||||||||||||
Generic (raw payload) | |||||||||||||||||||||||
Byte length of payload | Read/write | 04, 16 | YY40 | 1 | UINT_16 | none | - | ||||||||||||||||
Payload port | Read/write | 04, 16 | YY41 | 1 | UINT_16 | none | - | ||||||||||||||||
Payload Timestamp | Read/write | 04, 16 | YY42 | 4 | UINT_64 | ms | Timestamp (ms) Write function accepted, but no action done |
||||||||||||||||
Payload values | Read/write | 04, 16 | YY46 | 26 | HEX (52B) | none | Payload is concatenated up to 52 bytes with 0x00 Length of payload can be read with specific register Important : only last payload is available (no history) |
||||||||||||||||
RESOURCE DOCUMENTATION | |||||||||||||||||||||||
Data model structure | |||||||||||||||||||||||
Register tablel countain separated register areas to manage independently the gateway and data for each device: | |||||||||||||||||||||||
hx0000 to hx00FF are dedicated to the gateway data | |||||||||||||||||||||||
For each device YY (device index), a register range hxYY00 to hxYYFF is reserved | |||||||||||||||||||||||
hx0000 --> hx00FF | Gateway register area | ||||||||||||||||||||||
hx0100 --> hx01FF | Device 01 register area | ||||||||||||||||||||||
hx0200 --> hx02FF | Device 02 register area | ||||||||||||||||||||||
... | ... | ||||||||||||||||||||||
hxC800 --> hxC8FF | Device 200 register area | ||||||||||||||||||||||
Supported Modbus functions | |||||||||||||||||||||||
The SLgateway Modbus supports the following Modbus functions, dependant from the register address (in decimal): | |||||||||||||||||||||||
02 | Read multiple discrete inputs (read n bits) | ||||||||||||||||||||||
03 | Read multiple holding registers (read n 16-bits registers) | ||||||||||||||||||||||
04 | Read multiple input registers (read n 16-bits registers) | ||||||||||||||||||||||
16 | Write multiple holding registers (write n 16-bits registers) | ||||||||||||||||||||||
Resource format | |||||||||||||||||||||||
Except if mentioned, all device data are coded into one of the following format and processed as MSB first byte array. | |||||||||||||||||||||||
INT_16 | Signed integer value on 16 bits | ||||||||||||||||||||||
UINT_16 | Unsigned integer value on 16 bits | ||||||||||||||||||||||
INT_32 | Signed integer value on 32 bits | ||||||||||||||||||||||
UINT_32 | Unsigned integer value on 32 bits | ||||||||||||||||||||||
UINT_64 | Unsigned integer value on 64 bits | ||||||||||||||||||||||
FLOAT_32 | Real value (IEEE 754 floating-point "single format" bit layout) | ||||||||||||||||||||||
BOOL | boolean (0 is false, 1 is true) information on 1 bit | ||||||||||||||||||||||
ASCII | String
in ASCII code. The number of character is specified. When ASCII string are not full, they are completed with null bytes. |
||||||||||||||||||||||
HEX | String
in hexadecimal format. The number of bytes is specified. When Hexadecimal string are not full, they are completed with null bytes. |
||||||||||||||||||||||
TIMESTAMPS | Number of ms since the 1st jan of 1970 at 00h00 and the event on 64 bits. |