1
\$\begingroup\$

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?

\$\endgroup\$

1 Answer 1

1
\$\begingroup\$

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 }]}

\$\endgroup\$
1
  • 1
    \$\begingroup\$ Looks like this 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. \$\endgroup\$
    – cross
    Nov 21, 2016 at 8:20

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.