# Creating UDTs with MQTT Devices

**URL:** <https://forum.inductiveautomation.com/t/creating-udts-with-mqtt-devices/51048>\
**Category:** Ignition\
**Created:** [September 16, 2021, 8:37pm UTC](https://forum.inductiveautomation.com/t/creating-udts-with-mqtt-devices/51048 "2021-09-16T20:37:02Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![jacob.ramirez](https://avatars.discourse-cdn.com/v4/letter/j/9dc877/32.png) [@jacob.ramirez](https://forum.inductiveautomation.com/u/jacob.ramirez)\
**Post date:** [September 16, 2021, 8:37pm UTC](https://forum.inductiveautomation.com/t/creating-udts-with-mqtt-devices/51048/1 "2021-09-16T20:37:02Z")

</div>

Can someone help me understand how UDTs are used when using the MQTT Modules?

I am looking to use the MQTT modules but I am concerned about how I will utilize UDTs with it. I’ve seen webinars where the tags are auto-created when using these modules and the data comes in using Sparkplug protocol.

I am looking to use a Red Lion HMI which can publish data to an MQTT broker using their Sparkplug MQTT connector. So then the tags should auto-populate under the MQTT Engine tag provider.

If for example, I have 100 pumps that all have the same set of data tags publishing to the MQTT broker using this same HMI, how can I create UDTs if the tags are auto-created with the MQTT Engine Module?  
I want to be able to manage Ignition side alarms for those pumps from the Ignition server.

Any suggestions?

---

<div class="post-metadata">

**Author:** ![nminchin](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/nminchin/32/6911_2.png) [@nminchin](https://forum.inductiveautomation.com/u/nminchin)\
**Post date:** [September 16, 2021, 8:43pm UTC](https://forum.inductiveautomation.com/t/creating-udts-with-mqtt-devices/51048/2 "2021-09-16T20:43:06Z")

</div>

Quick reply for now. Don’t mind the typos  
We treat mqtt tag provider like any other (apart from ignition opc-ua} , as a source of data for igntion tags. We create udt definitions and tags in the igntiokn opc-ua that link to the mqtt tags usuijg Reference tags. This way we can manage all the config, alarms, properties, etc. From ignition. The only thing we use mqtt tags for is history for its backfill, by adding history into the mqtt tags.  
Otherwise you’re unable to add any supporting tags for ignition not coming from mqtt

This is also how another IA employee would do it I was in touch with at the time

---

<div class="post-metadata">

**Author:** ![jacob.ramirez](https://avatars.discourse-cdn.com/v4/letter/j/9dc877/32.png) [@jacob.ramirez](https://forum.inductiveautomation.com/u/jacob.ramirez)\
**Post date:** [September 16, 2021, 8:47pm UTC](https://forum.inductiveautomation.com/t/creating-udts-with-mqtt-devices/51048/3 "2021-09-16T20:47:20Z")

</div>

AWESOME. Thank you, I’ve been trying to figure that out all day. I was afraid I was going to have to manage them one by one or do some type of scripting or I don’t even know.

---

<div class="post-metadata">

**Author:** ![nminchin](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/nminchin/32/6911_2.png) [@nminchin](https://forum.inductiveautomation.com/u/nminchin)\
**Post date:** [September 16, 2021, 8:48pm UTC](https://forum.inductiveautomation.com/t/creating-udts-with-mqtt-devices/51048/4 "2021-09-16T20:48:55Z")

</div>

No worries. If it helps, you can use system.tag.configure to configure the history config on the mqtt tags so you don’t have to do this manually

---

<div class="post-metadata">

**Author:** ![jacob.ramirez](https://avatars.discourse-cdn.com/v4/letter/j/9dc877/32.png) [@jacob.ramirez](https://forum.inductiveautomation.com/u/jacob.ramirez)\
**Post date:** [September 16, 2021, 8:49pm UTC](https://forum.inductiveautomation.com/t/creating-udts-with-mqtt-devices/51048/5 "2021-09-16T20:49:33Z")

</div>

But why not do it on the reference tag in the UDT definition?

---

<div class="post-metadata">

**Author:** ![nminchin](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/nminchin/32/6911_2.png) [@nminchin](https://forum.inductiveautomation.com/u/nminchin)\
**Post date:** [September 16, 2021, 8:50pm UTC](https://forum.inductiveautomation.com/t/creating-udts-with-mqtt-devices/51048/6 "2021-09-16T20:50:04Z")

</div>

The you won't get backfill data if the comms fails ☹

> [@\[FEATURE\] Allow reference tags to receive backfill data from sources like MQTT tags](https://forum.inductiveautomation.com/t/feature-allow-reference-tags-to-receive-backfill-data-from-sources-like-mqtt-tags/48261):
>
> At the moment, if you have MQTT Engine connected to a device, and Ignition reference tags to reference the MQTT tags with history on, backfill data from MQTT doesn’t transfer to the reference tag if the connection to the MQTT device goes down. If you enable history on the MQTT tag itself, then it backfills fine once connection to the MQTT device is re-established. It would be great if this backfill data was transferred across to the tag(s) that reference it. Idea: [Allow reference tags to rece…](https://ideas.inductiveautomation.com/ignition-features-and-ideas/p/allow-reference-tags-to-receive-backfill-data-from-sources-like-mqtt-tags)

If you care about backfill of course, otherwise just use history on ignition tags. I had no choice as we needed it

---

<div class="post-metadata">

**Author:** ![jacob.ramirez](https://avatars.discourse-cdn.com/v4/letter/j/9dc877/32.png) [@jacob.ramirez](https://forum.inductiveautomation.com/u/jacob.ramirez)\
**Post date:** [September 16, 2021, 8:54pm UTC](https://forum.inductiveautomation.com/t/creating-udts-with-mqtt-devices/51048/7 "2021-09-16T20:54:50Z")

</div>

So your devices are using store and forward then?

---

<div class="post-metadata">

**Author:** ![nminchin](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/nminchin/32/6911_2.png) [@nminchin](https://forum.inductiveautomation.com/u/nminchin)\
**Post date:** [September 16, 2021, 9:05pm UTC](https://forum.inductiveautomation.com/t/creating-udts-with-mqtt-devices/51048/8 "2021-09-16T21:05:44Z")

</div>

Yep, I didn’t set up the mqtt side and don’t know the terminology, but store and forward sounds right

---

<div class="post-metadata">

**Author:** ![dcamp1](https://avatars.discourse-cdn.com/v4/letter/d/dc4da7/32.png) [@dcamp1](https://forum.inductiveautomation.com/u/dcamp1)\
**Post date:** [September 16, 2021, 9:53pm UTC](https://forum.inductiveautomation.com/t/creating-udts-with-mqtt-devices/51048/9 "2021-09-16T21:53:36Z")

</div>

I don’t use the Red Lion, but instead I use Maple Systems.

The MQTT Protocol allows you to have several layers of tag grouping.

I have "Well Data, Vfd Data, Flowline Data, Tank Data, Etc…

Here’s some you may want to read.  
[MQTT Sparkplug B](https://www.eclipse.org/tahu/spec/Sparkplug%20Topic%20Namespace%20and%20State%20ManagementV2.2-with%20appendix%20B%20format%20-%20Eclipse.pdf)

---

<div class="post-metadata">

**Author:** ![nminchin](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/nminchin/32/6911_2.png) [@nminchin](https://forum.inductiveautomation.com/u/nminchin)\
**Post date:** [September 17, 2021, 11:07am UTC](https://forum.inductiveautomation.com/t/creating-udts-with-mqtt-devices/51048/10 "2021-09-17T11:07:25Z")

</div>

Fwiw, we used folder structures in our mqtt tags that mimicked our folder and tag structure we used for our ignition tags. This made it easy to set the tag reference sources. However, I would still always use ignition tags from the OPC UA server as opposed to just looking at the mqtt provider tags, as it gives you flexibility to do whatever you want with them and to add supporting tags around them.

---

<div class="post-metadata">

**Author:** ![Mitchell\_Maziarz](https://avatars.discourse-cdn.com/v4/letter/m/6f9a4e/32.png) [@Mitchell\_Maziarz](https://forum.inductiveautomation.com/u/Mitchell_Maziarz)\
**Post date:** [October 24, 2024, 1:50pm UTC](https://forum.inductiveautomation.com/t/creating-udts-with-mqtt-devices/51048/11 "2024-10-24T13:50:11Z")

</div>

Been a while, but does this mean that instead of using MQTT Engine tags in projects, you are essentially creating a copy of the source tag provider that is publishing the Ignition tags over MQTT, changing all of the tags to reference tags, and pointing them at the MQTT engine tags?

i.e. Source provider -\> MQTT Engine -\> Copy of source provider as reference tags

---

<div class="post-metadata">

**Author:** ![nminchin](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/nminchin/32/6911_2.png) [@nminchin](https://forum.inductiveautomation.com/u/nminchin)\
**Post date:** [October 24, 2024, 11:40pm UTC](https://forum.inductiveautomation.com/t/creating-udts-with-mqtt-devices/51048/12 "2024-10-24T23:40:52Z")

</div>

Pretty much. MQTT engine uses a managed tag provider, so you have very little control over them

---

<div class="post-metadata">

**Author:** ![louagejasper](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/louagejasper/32/86311_2.png) [@louagejasper](https://forum.inductiveautomation.com/u/louagejasper)\
**Post date:** [October 25, 2024, 6:50am UTC](https://forum.inductiveautomation.com/t/creating-udts-with-mqtt-devices/51048/13 "2024-10-25T06:50:24Z")

</div>

Yup, so far that is the only practical way using MQTT tags imo.

---

<div class="post-metadata">

**Author:** ![Mitchell\_Maziarz](https://avatars.discourse-cdn.com/v4/letter/m/6f9a4e/32.png) [@Mitchell\_Maziarz](https://forum.inductiveautomation.com/u/Mitchell_Maziarz)\
**Post date:** [October 25, 2024, 11:17am UTC](https://forum.inductiveautomation.com/t/creating-udts-with-mqtt-devices/51048/14 "2024-10-25T11:17:07Z")

</div>

If all of the nodes that are feeding MQTT data are other Ignition gateways, what's the difference between this approach and using remote tag providers?

---

<div class="post-metadata">

**Author:** ![louagejasper](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/louagejasper/32/86311_2.png) [@louagejasper](https://forum.inductiveautomation.com/u/louagejasper)\
**Post date:** [October 25, 2024, 11:35am UTC](https://forum.inductiveautomation.com/t/creating-udts-with-mqtt-devices/51048/15 "2024-10-25T11:35:14Z")

</div>

Good question. It's definitely more 'hyped' to go the MQTT route because of UNS coming up so much.  
Imo, if you're not using your MQTT data onsite for anything else and if you don't have any other topics coming in then Ignition data, it's way faster to develop using RTP's.

One claim made by Cirrus Link is that the MQTT approach will scale more. Your main gateway will be able to handle way more tags if they come in over MQTT, because the tags are more lightweight. I do wonder if it's still the case when you need to duplicate them all into reference tags. Amount of tags they spoke of when we last had a chat was 200k tags vs 1million tags.

---

<div class="post-metadata">

**Author:** ![Theodorska](https://avatars.discourse-cdn.com/v4/letter/t/34f0e0/32.png) [@Theodorska](https://forum.inductiveautomation.com/u/Theodorska)\
**Post date:** [January 17, 2025, 9:03am UTC](https://forum.inductiveautomation.com/t/creating-udts-with-mqtt-devices/51048/16 "2025-01-17T09:03:29Z")

</div>

Update: nevermind, backfill is possible with referencetags [[FEATURE] Allow reference tags to receive backfill data from sources like MQTT tags - #16 by jhottell](https://forum.inductiveautomation.com/t/feature-allow-reference-tags-to-receive-backfill-data-from-sources-like-mqtt-tags/48261/16) had my answer

If I have understood this response and thread correctly, you use reference tags for interacting with the MQTT data, but you set up history directly on the incoming MQTT tags to allow backfill? Isn't it now possible to allow back fill in the reference tags tag group if we choose to set up history with them? Or should we continue to keep history enabled directly on the incoming mqtt tags?

---

<div class="post-metadata">

**Author:** ![Yousef\_Ali](https://avatars.discourse-cdn.com/v4/letter/y/87869e/32.png) [@Yousef\_Ali](https://forum.inductiveautomation.com/u/Yousef_Ali)\
**Post date:** [February 21, 2025, 11:15am UTC](https://forum.inductiveautomation.com/t/creating-udts-with-mqtt-devices/51048/17 "2025-02-21T11:15:15Z")

</div>

I used the same way , but i have a question here and asking for the best approach for that .  
I received MqttTag decoded in special format which need to be encoded to be readable .i am able to encode this fromat using scripting in each mqttTag change script and write the value in as a new Tag .

What's the best way to do encode . Add Tag change script on mqtt Tag but this way more static if new tag received in Mqtt Tag Folder. i have to back tod designer and add tagChange script .

---

<div class="post-metadata">

**Author:** ![pturmel](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/pturmel/32/3295_2.png) [@pturmel](https://forum.inductiveautomation.com/u/pturmel)\
**Post date:** [February 21, 2025, 1:17pm UTC](https://forum.inductiveautomation.com/t/creating-udts-with-mqtt-devices/51048/18 "2025-02-21T13:17:01Z")

</div>

> [@Yousef\_Ali](#):
>
> best way to do encode

Consider using a derived tag. You can decode from the custom format to a document type, and in the reverse direction, construct from document to encoded format. (If users will write to individual members of the document, be sure to use "optimistic writes" in the tag group.

---

<div class="post-metadata">

**Author:** ![nminchin](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/nminchin/32/6911_2.png) [@nminchin](https://forum.inductiveautomation.com/u/nminchin)\
**Post date:** [February 21, 2025, 1:27pm UTC](https://forum.inductiveautomation.com/t/creating-udts-with-mqtt-devices/51048/19 "2025-02-21T13:27:09Z")

</div>

> [@pturmel](#):
>
> If users will write to individual members of the document, be sure to use "optimistic writes" in the tag group

Does this apply for reading in structures as documents from Siemens opcua as well? Does this let you write values consecutively immediately?

---

<div class="post-metadata">

**Author:** ![pturmel](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/pturmel/32/3295_2.png) [@pturmel](https://forum.inductiveautomation.com/u/pturmel)\
**Post date:** [February 21, 2025, 1:29pm UTC](https://forum.inductiveautomation.com/t/creating-udts-with-mqtt-devices/51048/20 "2025-02-21T13:29:08Z")

</div>

> [@nminchin](#):
>
> structures as documents from Siemens opcua as well?

Yes.

> [@nminchin](#):
>
> Does this let you write values consecutively immediately?

Within a single `writeBlocking`, yes. Not for multiple independent writes, IIRC.

[Next page](https://forum.inductiveautomation.com/t/creating-udts-with-mqtt-devices/51048.md?page=2)
