IT-Consulting · Soft- & Hardware Engineering & Development · IoT · AI · Green-/Boat-/Navi-/Fin-Tech

IoT-Sensor Link

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.

Notation


Network-Layer

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.

Bit-Transfer

Packet-Frame

[sync:8] [head:4+4] [framelen:8/16] [payload:...] [crc:16]

  1. sync=0x55 constant value hex 55 (toggling bits from startbit, syncbyte, stopbit allow to detect the baud rate - inspired by LIN protocol)
  2. head type of packet-frame and used for start detection (should be checked for bit7=1 and then for nibble redundancy)
  3. framelen length of [payload] including the [crc] (allows skipping whole frames) but NOT including [head]
  4. payload bytes containing packet information and packet data
  5. crc CRC16-CCITT of [framelen] and [payload] but NOT including [head]

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 ...0undefined
...1 ...1undefined


Data-Layer

This specification of the data-layer allows any bus-member to read all types auf packages, without interpreting the content-types (syntactical parsing).

Data-Formats

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] FORMATPLAYLOAD LENGTHDESCRIPTION
0intentionally undefined
1[byte:8]11 byte integer value (LSb first)
2[word:16]22 byte integer value (LSb/MSB first)
3[long:32]44 byte integer value (LSb/MSB first)
4[huge:64]88 byte integer value (LSb/MSB first)
5[extra:128]1616 byte integer value (LSb/MSB first)
6
7[sign:1][range:2][exponent:5][fixpoint:16]316 bit fraction value in fixpoint representation
8[sign:1][range:2][exponent:5][fixpoint:32]532 bit fraction value in fixpoint representation
9[sign:1][range:2][exponent:5][fixpoint:64]964 bit fraction value in fixpoint representation
A[sign:1][range:2][exponent:5][fixpoint:128]17128 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.

Fraction-Values


Packet-Layer

This specification of the packet-layer allows the bus-member to walk through an interpret packets.

Information-Cascarding

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.

Payload

[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).

Properties

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] DATADESCRIPTION
Package Properties (for addressing, handling, encoding)
00intentionally undefined
01no command, bus keep alive, "hello" message
02reset bus state, resync bus
03bus 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)
10do reset, wakeup from sleep
11[centis:16]do sleep for [centies] 1/100 seconds or (if 0) sleep depending on own configuration
12do shutdown until powered up again (bus do not need to power down yet)
13
14
15
16
17do 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
A0sensor/actor number 0
A1sensor/actor number 1
...
AFsensor/actor number 15
 
FF[extproperty:8]Definition of extended properties (level 1) for future use

Units

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] UnitDescription
00-intentionally undefined
Temperature
01°CCelsius
02°FFahrenheit
03KKelvin
04°RéReaumur
05°NNewton
06°RaRankine
Volume
10cubic meter
11dm³cubic decimeter
12cm³cubic centimeter
13lliter
14dldeciliter
14clcentiliter
16mlmilliliter
17fl oz(UK)fluid ounce(UK)
18fl oz(US)fluid ounce(US)
19in³cubic inch
1Aft³cubic foot
1Byd³cubic yard
1Cgal(UK)gallon uk
1Dgal(US)gallon us
1Ebblpetroleum barrel
1Fpt(Imp)pint(UK)
20pt(US fl)fluid pint(US)
21pt(US dry)dry pint(US)
Distance
30kmkilometer
31mmeter
32dmdecimeter
33cmcentimeter
34mmmillimeter
35mimile
36ininch
37ftfoot
38ydyard
39nautical milenautical mile
Weight
40ttonne
41kgkilogram
42hghectogram
43ggram
44dgdecigram
45cgcentigram
46mgmilligram
47µgmicrogram
48caratcarat
49graingrain
4Aoz (av)ounce avoirdupois
4Blb (av)pound avoirdupois
4Ccwt(UK)long hundredweight
4Dcwt(US)short hundredweight
4Eton(UK)long ton
4Fton(US)short ton
50st(UK)stone
Area
60km²square kilometer
61square meter
62dm²square decimeter
63cm²square centimeter
64mm²square millimeter
65hahectare
66aare
67cacentiare
68mile²square mile
69in²square inch
6Ayd²square yard
6Bft²square foot
6Crorood
6Dacreacre
6Enautical mile²square nautical mile
Speed
80kmph = km/hkilometer per hour
81mps = m/smeter per second
82mph = mi/hmile per hour
83knot = nautical mile/hknot
84mamac
Databyte
A0bbit
A1Bbyte
A2KB (ex : 1 KB = 1024 bytes)kilobyte
A3MB (ex : 1 MB = 10242 bytes)megabyte
A4GB (ex : 1 GB = 10243 bytes)gigabyte
A5TB (ex : 1 TB = 10244 bytes)terabyte
A6PB (ex : 1 PB = 10245 bytes)petabyte
A7EB (ex : 1 EB = 10246 bytes)exabyte
A8ZB (ex : 1 ZB = 10247 bytes)zettabyte
A9YB (ex : 1 YB = 10248 bytes)yottabyte
Time
B01 year = 365 dayscommon year
B11 year = 366 daysleap year
B21 year = 365.2425 daysaverage Gregorian calendar year
B31 year = 365.25 daysaverage Julian calendar year
B41 year = 365.24219 daystropical year
B5weekweek
B6dayday
B7hhour
B8minminute
B9ssecond
BAmsmillisecond
BBµsmicrosecond
BCnanosecondnanosecond
BDpicosecondpicosecond
BEfemtosecondfemtosecond
BFattosecondattosecond
Frequency
D0HzHertz
D1KHzKilohertz
D2MHzMegahertz
D3GHzGigahertz
Pressure
E0atmAtmosphère
E1barBar
E2mbarMillibar
E3PaPascal
E4hPaHectopascal
E5PsiPounds per square inch
E6TorrTorr
Energy
F0JJoule
F1KJKilojoule
F2calCalorie
F3kcalKilocalorie
F4WhWatt-hour
F5kWhKilowatt-hour
F6BTUBritish thermal unit
F7thmTherm américain
F8ft-lbFoot-Pound
Humidity
FA%RHpercent relative humidity
FFDefinition of extended units (level 1) for future use