CLICK PLC is now offering MQTT on the CLICK PLUS CPUs. MQTT is an extremely simple and
lightweight messaging protocol and is a great way to pass data between multiple platforms
without a lot of protocol confusion and very little development time.
Messaging in MQTT is based upon Topics. These can either be subscribed to or published to
from a central repository. This central repository of topics is called a Broker.
The devices subscribing or publishing to this broker are called Clients. Each
client can publish or subscribe to one or more of the topics on the Broker.
First, you must have a CLICK PLUS CPU that has version 3.0 software or above. The CLICK PLUS CPU
can only work as a client. You must have already set up an MQTT Broker to handle the messaging. There
are too many different MQTT Brokers and their setups are way too varied to cover in this video.
Please see MQTT.org for more information on this topic. For the purposes of this video, I am using
a Raspberry PI 4 with Mosquito loaded. There is a really good tutorial on this setup, and you can
find a link to that in the description below. CLICK has made using MQTT very simple.
It does not require any instructions in your ladder code. To set up MQTT,
go to the Function tab and then select MQTT setup. Here you can enable MQTT.
Then you have the option to enable subscribe, publish or both.
When you enable the Client setup, if you select subscribe you get 1 subscribe setup, and if you
select publish you will get up to 4 blocks. Let’s start with the MQTT Client setup.
Here you can place either the server name or the direct IP Address of your broker. If
you are going to use the server name, you must have setup DNS setup on your Click Plus.
I am on an isolated network with a static IP address from my Raspberry Pi
so I will enter that in here. Protocol is, of course, MQTT.
The standard server port for MQTT is 1883, consult your broker information,
to ensure that this number is correct. Enter a bit to monitor the connection
status and this will be helpful in troubleshooting if you have problems.
If your broker requires Authentication enter that here.
This last will option is used to notify that there has been a disconnect
of this client. This is a topic that will be maintained at the Broker, and not published
unless the Client has dropped connection. And here, you can enter a Custom Client ID.
Now, I am going to enable the subscribe by selecting here.
Enter a bit to enable the reading of the Topic.
And here you can define the the action of that bit.
Then place a bit for the error status and reading the error code.
Select here and you will bring up the possible Broker topics. Select the Edit mode and you can
enter in the topic name. Setting up my Broker, it created a test topic that I will enter here.
The test message already in my Broker is “Hello World!”,
which is 12 characters. So I will use txt address 1 -12 to display this.
If you select this, you will be able to see this messaging from the MQTT text view, which is a
troubleshooting tool you will see later. Now, before I go on to publish, let’s
send this to the CPU and do a quick display of this works.
I am going to open a data view and put my connection status bit,
enable bit, error bit, error code, and the text addresses that this will be loaded into.
Once I enable the bit. I see the text addresses fill out the topic message.
And if I open the MQTT text view you will see the same here.
Let’s go back and create a publish message to change this topic message.
Enable the publish here. Place an enable, success,
error bit and then the error code. I will use the same topic we created before.
The payload, now before we begin, if you are placing static text, it must be encapsulated
with quotation marks. You can also place an embedded memory address
that does not require quotations. I will use DS20 and set that up to be 2 fixed digits.
Now, I am going to back out of all of this. I am going to send it to my PLC.
I am going to add onto my data view, the publish bits and the DS20 into my data view.
I will enable the publish. And our new message is present and if we change DS20
and then reenable the publish. The changes are made.
Nice and easy way to pass information between multiple platforms
Once again, CLICK is making advanced simple.
If you have any question about this video, please feel free to comment below or call into our
technical support team. Please follow this link to see more videos on the CLICK PLUS platform
and select here to subscribe to our YouTube channel for upcoming news and solutions.