Author Topic: efficient packing of mcmodule data in mqtt message  (Read 83 times)

travelbug

  • Newbie
  • *
  • Posts: 4
    • View Profile
efficient packing of mcmodule data in mqtt message
« on: April 28, 2017, 01:44:47 pm »
Apologies if this has already been asked -

Is there an efficient way of sending all the available information in a mcmodule in a single message?  I believe the amount of power/time it takes to just send the temp, I might as well get all the data (time/3axis/temp/batt voltage/IO states/etc and anything else available?)  At that point I can determine which ones I want to listen to, but if they are all available it is probably a lot more code efficient to do one send as opposed to many?  Any examples would surely be appreciated.

Thanks,
Martin.

Social Buttons


mc-John

  • Global Moderator
  • Full Member
  • *****
  • Posts: 212
    • View Profile
Sending over mcAir (range 200m) is very low power so don't worry much about making the message as small as possible. Sending 3 messages is more expensive then 1 bigger message so combine messages if possible to one but don't go over 100 bytes.
Sending over Sigfox (range 30miles) is very expensive so pack your info as much as possible.

Packing can be done with the ListOfByte object and understanding your data.
For example a temperature can be packed in a byte. Give it an offset of 100F so 100=0F, 220=120F and 60 = -40F.

See example in attachment, where the one byte temperature and a 2 byte (Short) voltage is packed in a 3 byte message