# Encoding payloads for sparkplug\_b\_v1\_0\_Protobuf

**URL:** <https://forum.cirrus-link.com/t/encoding-payloads-for-sparkplug-b-v1-0-protobuf/259>\
**Category:** Ignition Modules\
**Tags:** mqtt-transmission\
**Created:** [September 28, 2022, 9:52pm UTC](https://forum.cirrus-link.com/t/encoding-payloads-for-sparkplug-b-v1-0-protobuf/259 "2022-09-28T21:52:17Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![hboyd](https://avatars.discourse-cdn.com/v4/letter/h/74df32/32.png) [@hboyd](https://forum.cirrus-link.com/u/hboyd)\
**Post date:** [September 28, 2022, 9:52pm UTC](https://forum.cirrus-link.com/t/encoding-payloads-for-sparkplug-b-v1-0-protobuf/259/1 "2022-09-28T21:52:17Z")

</div>

I am gathering high-frequency data (1ms-5ms) from a JSON payload via OPC  
I have attempted multiple methods using the traditional tag-based system.tag.writeBlocking() to transmit this data to our MQTT server, but the tag groups can only poll 1ms and it misses about 80% of the data.

I would like to take an input array of objects and transmit them iteratively using system.cirruslink.transmission.publish

Fiddling around, I have an input and an output from the google protobuf payload:

```auto
timestamp: 1664396472110
metrics {
  name: "pressure"
  timestamp: 1664396472110
  datatype: 9
  float_value: 173.15607
}
seq: 3

```

gets turned into

```auto
b"\x08\xae\xde\x8a\xae\xb80\x12\x18\n\x08pressure\x18\xae\xde\x8a\xae\xb80 \te\xf4'-C\x18\x03"

```

It’s not elegant, but I’d like to brute-force together a specific bytearray to transmit this data correctly.  
Does anyone know the structure.pack formats for timestamp, float, etc?

---

<div class="post-metadata">

**Author:** ![wes.johnson](https://avatars.discourse-cdn.com/v4/letter/w/f14d63/32.png) [@wes.johnson](https://forum.cirrus-link.com/u/wes.johnson)\
**Post date:** [September 28, 2022, 11:04pm UTC](https://forum.cirrus-link.com/t/encoding-payloads-for-sparkplug-b-v1-0-protobuf/259/2 "2022-09-28T23:04:16Z")

</div>

There is much more complexity to a true Sparkplug Edge Node than simply using the protobuf encoding for a Sparkplug payload. You can certainly implement your own Sparkplug client - but it probably won’t be easy.

Instead, I would suggest looking at MQTT Engine custom namespaces. You can use a standard JSON payload encoding with the publish API. Take a look here: [MQTT Engine Custom Namespace - MQTT Modules for Ignition 8.x - Confluence](https://docs.chariot.io/display/CLD80/MQTT+Engine+Custom+Namespace)

With this method, you don’t have to deal with all of the ‘state’ aspects of Sparkplug and can simply publish your JSON based payloads to MQTT Engine.
