Different sensors can be attached to our IoT-Stations. Our simple Sensor-Link Protocol allows the development and connection of new sensors.
The communication runs over a half-duplex RS485 connection in multi-master operation mode. So each sensor can send its measurement without the need of constant asking by some sort of "master".
The line can be sequentially extended (line topology) and contains 4 wires with differential RS485+ RS485- signals, GND and 3.3V. Our sensors have automatically switched 120 Ohm termination resistors at the line endings.
We use 4 pin 2.5mm audio jacks, because the wires are thin and the connectors are small (about Ø5mm), so a small hole can be drilled for placing the sensors inside different devices.
[name:8]
Data "name" coded in 8 bits[name:76543210]
Data "name" coded in 8 bits described later[name:32]
Data "name" coded as 32 bit value
This specification of the network-layer allowes each bus-member to read (without parsing) or skip packet-frames. So the bus-state can be anaysed to get a free bus-slot.
[number:16]
is transferred as [number bits 8..15][number bits 0..7]
and[number:32]
is transferred as [number bits 24..31][number bits 16..23][number bits 8..15][number bits 0..7]
[sync:8] [head:4+4] [framelen:8/16] [payload:...] [crc:16]
The head byte is used for detection of the packet-frame and used for configuration. The 4bit nibbles are cloned to give proper redundancy on sync start.
[HEAD:7654][HEAD:3210] | DESCRIPTION |
---|---|
0... 0... | forbidden (could result in the sync byte 0x55) |
1... 1... | always 1 to separate head from sync byte 0x55 |
.00. .00. | undefined |
.01. .01. | length = 8 bit value, no crc used (validity ensured by stop-bit framing only) |
.10. .10. | length = 8 bit value, 16-bit crc appended (and added to framelen) |
.11. .11. | length = 16 bit value, 16-bit crc appended (and added to framelen) |
...0 ...0 | undefined |
...1 ...1 | undefined |
This specification of the data-layer allows any bus-member to read all types auf packages, without interpreting the content-types (syntactical parsing).
All protocol interpreting devices should at least implement the size of payload to skip them while interpreting the package. Nethertheless a complete frame can be skipped by its [framelen] information.
TYPEID [hex] | FORMAT | PLAYLOAD LENGTH | DESCRIPTION |
---|---|---|---|
0 | intentionally undefined | ||
1 | [byte:8] | 1 | 1 byte integer value (LSb first) |
2 | [word:16] | 2 | 2 byte integer value (LSb/MSB first) |
3 | [long:32] | 4 | 4 byte integer value (LSb/MSB first) |
4 | [huge:64] | 8 | 8 byte integer value (LSb/MSB first) |
5 | [extra:128] | 16 | 16 byte integer value (LSb/MSB first) |
6 |
| ||
7 | [sign:1][range:2][exponent:5][fixpoint:16] | 3 | 16 bit fraction value in fixpoint representation |
8 | [sign:1][range:2][exponent:5][fixpoint:32] | 5 | 32 bit fraction value in fixpoint representation |
9 | [sign:1][range:2][exponent:5][fixpoint:64] | 9 | 64 bit fraction value in fixpoint representation |
A | [sign:1][range:2][exponent:5][fixpoint:128] | 17 | 128 bit fraction value in fixpoint representation |
B |
| ||
C |
| ||
D | [len:8][rawdata:...] | [len] | Byte sequence - mostly String encoded in UTF-8, [len] defines the bytecount not the (multi byte-)charactercount |
E | [len:16][rawdata:...] | [packetlen] | Byte sequence - mostly an enveloped packet-frame where [rawdata] includes [head] [framelen] [payload] [crc] |
F |
|
The semantic interpretation of the value (signed, unsigned, string, time) is done in the context of the packet stream.
[sign:1][range:2][exponent:5][fixpoint:16]
3 bytes in total[sign:1][range:2][exponent:5][fixpoint:32]
5 bytes in total[sign:1][range:2][exponent:5][fixpoint:64]
9 bytes in totalThis specification of the packet-layer allows the bus-member to walk through an interpret packets.
The package sets states which remains active until bus-reset or the state is overwritten by the same originator. This information-cascarding allows compressing streams of values to the changed data only.
[property1:8] [data1] [property2:8] [data2] ... [propertyN:8] [dataN]
The payload is a collection of [property]
and [data]
pairs. Each [property]
is defined for a special purpose and the related [data]
is interpreted belonging to that case. The properties can be seen as data specifiers that define dataprocessing rules.
Application level functions can be described by several [property]
[data]
pairs containing the semantical implication. In meaningful cases, the properties can be interpreted in cascading manner. For example (written as extended plain text): [sensorname]
Cooler 34 upper [measureclass]
Temperature [measureunit]
°C [measurevalue]
23.450
If a property is unknown, it is not possible to parse the rest of the payload because the length of each [data]
segment cannot be determined. So the remaining payload can be skipped via the [len]
field of the packet frame. In this case the receiver is "incompatible" (or too old).
The important protocol related [property]
[data]
pairs are placed at the very beginning of each payload. These should be interpreted by all devices to response accordingly.
Each device may contain several sensors/actors (temperature, humidity, devicevoltage) that could response in thier own timing.
PROPERTY [hex] | DATA | DESCRIPTION |
---|---|---|
Package Properties (for addressing, handling, encoding) | ||
00 | intentionally undefined | |
01 | no command, bus keep alive, "hello" message | |
02 | reset bus state, resync bus | |
03 | bus is powering down now, devices should shutdown immediately | |
04 | ||
05 | ||
06 | ||
07 | ||
08 | ||
09 | ||
0A | [toaddress:32] | packet is for device [toaddress] only (from address is 2A) |
0B | ||
0C | ||
0D | ||
0E | ||
0F | ||
Command Properties (reveiving device should to that) | ||
10 | do reset, wakeup from sleep | |
11 | [centis:16] | do sleep for [centies] 1/100 seconds or (if 0) sleep depending on own configuration |
12 | do shutdown until powered up again (bus do not need to power down yet) | |
13 | ||
14 | ||
15 | ||
16 | ||
17 | do respond with device information (blocks 30 and 40) | |
18 | ||
19 | ||
1A | ||
1B | ||
1C | ||
1D | ||
1E | ||
1F | ||
Status Properties (device should send that as response or for information) | ||
20 | [lastreccrc:16] | Acknowledge that last received CRC is OK |
21 | [lastreccrc:16] | Acknowledge that last received CRC is BAD |
22 | [ackid:8] | Acknowledge last Package with [ackid] |
23 | ||
24 | ||
25 | [lastsentcrc:16] | Retransmission of CRC from last package for stream chaining |
26 | ||
27 | ||
28 | ||
29 | ||
2A | [fromaddress:32] | packet is originating from device [fromaddress] (to address is 0A) |
2B | ||
2C | ||
2D | ||
2E | ||
2F | ||
Identification Device Properties (as response to a "device information" request (17) | ||
30 | [name:STR0] | my manufacture name |
31 | [name:STR0] | my product name |
32 | [name:STR0] | my product function |
33 | ||
34 | [serial:32] | my serialnumber |
35 | ||
36 | ||
37 | ||
38 | ||
39 | ||
3A | ||
3B | ||
3C | ||
3D | ||
3E | [name:STR0] | my custom place (user configurable) |
3F | [name:STR0] | my custom id (user configurable) |
Identification Sensor/Actor Properties (as response to a "device information" request (17) | ||
40 | [name:STR0] | my function purpose ("temperature", "pressure", "textoutput") |
41 | [name:STR0] | my measurement unit |
42 | [datatype:4] | my datatype of measured values (using lower 4 bits only) |
43 | [mode:76543210] | 7 0 read only (sensor), 1 writeable (actor)6 5 4 3 2 1 0 |
44 | [value] | Minimum measurement value, type depending on definition 0x42, min length (unsigned word) for strings |
45 | [value] | Maximum measurement value, type depending on definition 0x42, max length (unsigned word) for strings |
46 | ||
47 | ||
48 | ||
49 | ||
4A | ||
4B | ||
4C | ||
4D | ||
4E | [name:STR0] | my custom place (user configurable) |
4F | [name:STR0] | my custom id (user configurable) |
Indicates that the following properties refer to the specified sensor/actor | ||
A0 | sensor/actor number 0 | |
A1 | sensor/actor number 1 | |
... | ||
AF | sensor/actor number 15 | |
FF | [extproperty:8] | Definition of extended properties (level 1) for future use |
To reduce convertion losses, each sensor should keep its native unit and scale, so if a sensor measures kV (kilo Volt) it should not return V (Volt).
Code [hex] | Unit | Description |
---|---|---|
00 | - | intentionally undefined |
Temperature | ||
01 | °C | Celsius |
02 | °F | Fahrenheit |
03 | K | Kelvin |
04 | °Ré | Reaumur |
05 | °N | Newton |
06 | °Ra | Rankine |
Volume | ||
10 | m³ | cubic meter |
11 | dm³ | cubic decimeter |
12 | cm³ | cubic centimeter |
13 | l | liter |
14 | dl | deciliter |
14 | cl | centiliter |
16 | ml | milliliter |
17 | fl oz(UK) | fluid ounce(UK) |
18 | fl oz(US) | fluid ounce(US) |
19 | in³ | cubic inch |
1A | ft³ | cubic foot |
1B | yd³ | cubic yard |
1C | gal(UK) | gallon uk |
1D | gal(US) | gallon us |
1E | bbl | petroleum barrel |
1F | pt(Imp) | pint(UK) |
20 | pt(US fl) | fluid pint(US) |
21 | pt(US dry) | dry pint(US) |
Distance | ||
30 | km | kilometer |
31 | m | meter |
32 | dm | decimeter |
33 | cm | centimeter |
34 | mm | millimeter |
35 | mi | mile |
36 | in | inch |
37 | ft | foot |
38 | yd | yard |
39 | nautical mile | nautical mile |
Weight | ||
40 | t | tonne |
41 | kg | kilogram |
42 | hg | hectogram |
43 | g | gram |
44 | dg | decigram |
45 | cg | centigram |
46 | mg | milligram |
47 | µg | microgram |
48 | carat | carat |
49 | grain | grain |
4A | oz (av) | ounce avoirdupois |
4B | lb (av) | pound avoirdupois |
4C | cwt(UK) | long hundredweight |
4D | cwt(US) | short hundredweight |
4E | ton(UK) | long ton |
4F | ton(US) | short ton |
50 | st(UK) | stone |
Area | ||
60 | km² | square kilometer |
61 | m² | square meter |
62 | dm² | square decimeter |
63 | cm² | square centimeter |
64 | mm² | square millimeter |
65 | ha | hectare |
66 | a | are |
67 | ca | centiare |
68 | mile² | square mile |
69 | in² | square inch |
6A | yd² | square yard |
6B | ft² | square foot |
6C | ro | rood |
6D | acre | acre |
6E | nautical mile² | square nautical mile |
Speed | ||
80 | kmph = km/h | kilometer per hour |
81 | mps = m/s | meter per second |
82 | mph = mi/h | mile per hour |
83 | knot = nautical mile/h | knot |
84 | ma | mac |
Databyte | ||
A0 | b | bit |
A1 | B | byte |
A2 | KB (ex : 1 KB = 1024 bytes) | kilobyte |
A3 | MB (ex : 1 MB = 10242 bytes) | megabyte |
A4 | GB (ex : 1 GB = 10243 bytes) | gigabyte |
A5 | TB (ex : 1 TB = 10244 bytes) | terabyte |
A6 | PB (ex : 1 PB = 10245 bytes) | petabyte |
A7 | EB (ex : 1 EB = 10246 bytes) | exabyte |
A8 | ZB (ex : 1 ZB = 10247 bytes) | zettabyte |
A9 | YB (ex : 1 YB = 10248 bytes) | yottabyte |
Time | ||
B0 | 1 year = 365 days | common year |
B1 | 1 year = 366 days | leap year |
B2 | 1 year = 365.2425 days | average Gregorian calendar year |
B3 | 1 year = 365.25 days | average Julian calendar year |
B4 | 1 year = 365.24219 days | tropical year |
B5 | week | week |
B6 | day | day |
B7 | h | hour |
B8 | min | minute |
B9 | s | second |
BA | ms | millisecond |
BB | µs | microsecond |
BC | nanosecond | nanosecond |
BD | picosecond | picosecond |
BE | femtosecond | femtosecond |
BF | attosecond | attosecond |
Frequency | ||
D0 | Hz | Hertz |
D1 | KHz | Kilohertz |
D2 | MHz | Megahertz |
D3 | GHz | Gigahertz |
Pressure | ||
E0 | atm | Atmosphère |
E1 | bar | Bar |
E2 | mbar | Millibar |
E3 | Pa | Pascal |
E4 | hPa | Hectopascal |
E5 | Psi | Pounds per square inch |
E6 | Torr | Torr |
Energy | ||
F0 | J | Joule |
F1 | KJ | Kilojoule |
F2 | cal | Calorie |
F3 | kcal | Kilocalorie |
F4 | Wh | Watt-hour |
F5 | kWh | Kilowatt-hour |
F6 | BTU | British thermal unit |
F7 | thm | Therm américain |
F8 | ft-lb | Foot-Pound |
Humidity | ||
FA | %RH | percent relative humidity |
FF | Definition of extended units (level 1) for future use |