1

I want to communicate various sensor data in a network of sensors.

I found MQTT and MQTT-SN as suitable protocols for that. The latter being better suited for sensor networks with support for sleeping devices, predefined communication, alternatives to TCP, etc. (https://stackoverflow.com/a/29083422)

However, both are payload agnostic. The message sent can be of arbitrary format and content. Is there a common format specifically for sensor data with small footprint?

I'd like to communicate a measurement value of a specified unit and dimensionality. Maybe with a specified tolerance/expected error. I could come up with a custom format and just shove it into the payload, but I do not want to reinvent the wheel and rather use existing formats if any exist. That would also ensure compatibility to other networks that use this format.

I found

  • an experimental proposal for an extension to XMPP which supports things like Unit or Timestamp. However, the overhead of the format being XML based makes it undesirable for my application.

    <message from='device@example.org'
             to='client@example.org/amr'>
       <fields xmlns='urn:xmpp:iot:sensordata' seqnr='1' done='true'>
          <node nodeId='Device01'>
             <timestamp value='2013-03-07T16:24:30'>
                <numeric name='Temperature' momentary='true' automaticReadout='true' value='23.4' unit='°C'/> 
             </timestamp>
          </node>
       </fields>
    </message>
    
  • Home Assistant, which specifies a format that also has unit_of_measurement and value_template. But this is more about extracting data from arbitrary MQTT messages into a format of the platform instead of specifying a format for the MQTT message itself. In fact, people write extensions to use JSON in the MQTT message

Is there simply no such thing as a standard (or at least common) lightweight message format for sensor data?

cross
  • 51
  • 1
  • 1
  • 6

1 Answers1

1

Media Types for Sensor Markup Language (SENML) may be interesting for you.

Chapter 6.1.1. gives you an example:

{"e":[{ "n": "urn:dev:ow:10e2073a01080063", "v":23.5 }]}

arminb
  • 1,622
  • 4
  • 21
  • 34
  • 1
    Looks like [this](https://tools.ietf.org/html/draft-ietf-core-senml-04#section-11.1) is the most recent version. I was scared away at first when seeing JSON format, but there's also EXI which looks rather compact and suitable for embedded. It looks like there are only a few libraries out there for this. – cross Nov 21 '16 at 08:20