title: Data format to use on a micro controller and MQTT
body: <p>I'm using <strong>MQTT</strong> on an <strong>Arduino</strong> to send sensors data to a Javascript page.</p>
  
  <p>Until now I've sent only simple data format: int or floats.</p>
  
  <p>What format can I use to send more complex, structured data?
  for example:</p>
  
  <pre><code>{ "temperature": 32, "humidity": 67 }
  </code></pre>
  
  <p>I'd like to send it on a single MQTT message.</p>
  
  <p>I could use Json, but I fear it's a bit heavy for an Arduino.</p>
  
  <hr>
  
  <p><strong>Update</strong></p>
  
  <p>Ok, seems to be a general consensus on JSON, however I'm a bit concerned about the memory requirement.</p>
  
  <p>I've found two libraries for json encoding/decoding on an Arduino:</p>
  
  <ul>
  <li><a href="https://github.com/bblanchon/ArduinoJson" rel="nofollow">https://github.com/bblanchon/ArduinoJson</a></li>
  <li><a href="https://github.com/interactive-matter/aJson" rel="nofollow">https://github.com/interactive-matter/aJson</a></li>
  </ul>
  
  <p><strong>ArduinoJson</strong> claims to be less memory consuming, however doesn't support:</p>
  
  <ul>
  <li>reading from Stream (<a href="http://ecafe.org/blog/2014/01/29/stream-support-for-arduino-mqtt-library.html" rel="nofollow">latest versions</a> of the Arduino MQTT library supports receiving 
  messages in streams)</li>
  <li>filtering of incoming json (to selectively parse only required Json fields)</li>
  </ul>