# How to publish binary data

**URL:** <https://community.particle.io/t/how-to-publish-binary-data/36142>\
**Category:** Firmware\
**Created:** [September 20, 2017, 7:08pm UTC](https://community.particle.io/t/how-to-publish-binary-data/36142 "2017-09-20T19:08:38Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![bittailor](https://sea2.discourse-cdn.com/flex026/user_avatar/community.particle.io/bittailor/32/7293_2.png) [@bittailor](https://community.particle.io/u/bittailor)\
**Post date:** [September 20, 2017, 7:08pm UTC](https://community.particle.io/t/how-to-publish-binary-data/36142/1 "2017-09-20T19:08:38Z")

</div>

I would like to publish 100 `uint16_t` values at once. I would like to publish them as binary value since then they fit into the 255 bytes of the data field:

> optional data (up to 255 bytes)

Unfortunately the `Particle.publish(const char *eventName, const char *data)` only takes an ´const char \*´ and no length and uses internally `strlen()` to calculate the length of the data which prevents sending binary data.

So the only way I found is encoding the binary data with a Base64 so I can send it as a string, but Base64 adds 33% overhead and with this my 100 `uint16_t` do not fit one publish anymore.

Is there another way to publish binary data without the overhead of an encoding?

---

<div class="post-metadata">

**Author:** ![ScruffR](https://sea2.discourse-cdn.com/flex026/user_avatar/community.particle.io/scruffr/32/6952_2.png) [@ScruffR](https://community.particle.io/u/ScruffR)\
**Post date:** [September 20, 2017, 7:33pm UTC](https://community.particle.io/t/how-to-publish-binary-data/36142/2 "2017-09-20T19:33:06Z")

</div>

You can also use Base85 but raw binary data can’t be transported via the cloud functions.  
But TCP/UDP transport can send (unencrypted) binary data, but then you can also ignore the 255 byte limit.

`Particle.variable()` strings can only be requested not pushed, but a string variable can be as long as 622 characters.

---

<div class="post-metadata">

**Author:** ![bittailor](https://sea2.discourse-cdn.com/flex026/user_avatar/community.particle.io/bittailor/32/7293_2.png) [@bittailor](https://community.particle.io/u/bittailor)\
**Post date:** [September 20, 2017, 8:01pm UTC](https://community.particle.io/t/how-to-publish-binary-data/36142/3 "2017-09-20T20:01:53Z")

</div>

Thank you for the different options.

I will probably go with Base85 with the 25% overhead my 100 `uint16_t` values fit into the 255 bytes limit.

_Raw_ TCP/UDP transport is no option since I have no server side that supports it.  
The variable is no option since I need to push them from the device since the device will be most of the time offline to save power.
