Hello!
I'm working on using MQTT with ignition through the Cirrus Link modules. I currently have my Ignition server receiving tag values (from a DHT22 temp/humidity sensor) with no issues. What I'm now working on is trying to figure out how to transmit a tag value - in my case a pump value which is either 0 or 1. My module sends it just fine but it sends too much information and the ESP8266 that I'm using can't decode the message being sent. I'd like to have the transmitter only send the tag value, ie. 0 or 1. Currently, it sends a whole bunch of tag properties along with it that can't be decoded.
Here is what the transmitter is sending (decoded with the spark plug decoder):
{"timestamp":1601397553975,"metrics":[{"name":"Pump","timestamp":1601397551790,"dataType":"String","properties":{"Quality":{"type":"Int32","value":192}},"value":"0th"}],"seq":24}
Here is the same thing in plain text:
�����.(
Pump�����. 8J
Quality�z0th
Finally, this is what the other end reads it as through the serial port:
Message arrived [spBv1.0/Plant/NDATA/Plant] ⸮⸮⸮⸮⸮.&
Pump⸮⸮⸮⸮⸮. 8
I'd like to just have ignition send the tag value and nothing more through the topic "spBv1.0/Plant/NDATA/Plant" so I don't have any issues decoding. Is this possible?
You should probably be using a generic namespace and not a Sparkplug namespace if the two sides don’t both understand Sparkplug.
How would I go about doing this? Currently I’m using a custom namespace that subscribes to various topics. I don’t see anything to change from Sparkplug other than the Encoding Charset property and the JSON Payload property.
https://docs.chariot.io/display/CLD80/ME%3A+Configuration search for “Custom Namespaces”.
Although now I seem to remember that tags from custom namespaces are read-only and you need to use the MQTT scripting calls to publish in that case.
I’m actually looking to have Ignition transmit a memory tag that I created. It isn’t receiving anything for that tag, it just needs to transmit its value. I don’t believe I even need to use namespaces in this case, only the transmitter module. It seems though the transmitter module only works with sparkplug though. I do see the filter property in the transmitter module, but I’m not sure how it works and couldn’t find any documentation online regarding its inputs.
I think you would want the engine module and this scripting function: https://docs.chariot.io/display/CLD79/Gateway+Script+MQTT+Publishing
1 Like
Thank you for the help, Kevin! For anyone else who may stumble across this having the same issue. I followed the tutorial Kevin posted but edited the scripting a bit to send the tag value rather than “hello world” when the tag value changes.
Here’s a copy of my script:
buff = system.tag.read("[MQTT Engine]Edge Nodes/Plant/Plant/Pump")
system.cirruslink.engine.publish("Chariot SCADA", "Pump", str(buff.value).encode(), 0, 0)
2 Likes
Hello.
We are working on communicating back and forth with some MQTT IO devices and think this may be applicable as an option for device feedback. We have the read topics coming in through engine module, but it seems like transmission module predefines a topic syntax so we can’t use that to write back to the device?
When we try just using the sample from a cirrus link doc (below) for transmission in a script it works to send the a/b/c topic to our ActiveMQ broker, but with these MQTT IO devices the message needed includes some quotations and I think this has been messing up how we need to format the payload.
I’ve posted an image that hopefully comes through ok with a sample from the MQTT doc for these devices on how to write a message to them. I’d appreciate any help with troubleshooting how to get this script to write successfully or some more info on the setup difference for using the engine version of the publish as displayed earlier in this thread.
Thank you,
Ed
https://docs.chariot.io/display/CLD80/MQTT+Publishing+via+MQTT+Transmission
Hi Matthew,
I am trying to publish DHT11 Sensor Value from NodeMCU to Ignition Over MQTT and I am getting it, now Apart from Gateway Script you have posted is there any other way to publish data from Ignition to MQTT or back to NodeMCU ? Because If I am publishing some data from NodeMCU to Ignition then I am not able to write or publish values to same MQTT topic from Ignition.
and If possible can you share you arduino code and Ignition Gateway backup for your DHT22 Project on my mail "eng.innovativ@gmail.com".
Thanks.
Thank you for the help !!
This sorted everything out. (almost)
I had to change the code from : buff.value to : currentValue.value
Then MQTT send the Sensor Value to one specific topic !
Cheers