mqtt iot stands for message cueing telemetry transport
and is a protocol in the popularly growing system of iot or the internet of things
this system consists of interrelated devices automatically exchanging data with one another
however devices that use mqtt do not directly exchange data with one another instead they
utilize an mqtt broker all kinds of devices utilize mqtt like coffee makers, thermostats,
temperature sensors, cell phones, and yes brix plc's some or all these devices might make
some of their data available to other devices by publishing that data to the broker other devices
might need that data and so these devices will subscribe to those data via the broker usually
devices do one or the other the brx plc can do both what does the broker do it receives published
topics it distributes topics to subscribers and it sends the last will and testament or the lwt to
subscribers if a client ungracefully disconnects that is dies so to speak what does the client do
a client provides the broker with his own keep a lifetime and qos or quality of service optionally
he can publish his own topics their associated retain bit and his own last will and testament
optionally he can also subscribe to topics so what is a topic very simply a topic is the name
you give to the data like temperature or psi or whatever how about payload
payload is the value the topic has in other words if the topic is temperature then the payload would
be say 79 degrees f message this is the topic plus the payload this is actually what's exchanged
between broker and client what is the qos or quality of service there are three values for
the quality of service zero one and two zero is at most once and it means that a message is sent once
it relies on tcpip to get the message to the interested device one is at least once and this
means that a message will be transmitted until an acknowledgement is received from the receiver
so it could be transmitted multiple times but guarantees the receiver gets it at least once
two is exactly once and this means that the message needs not only an acknowledgement from
the receiver but other qualifying exchanges as well the brx plc does not use a qos of two
retain this bit is associated with a published topic and it tells the broker whether or not to
retain this topic even after sending it to the subscribers if it is set to not retain
then the broker will delete the topic after it has sent it to this to the subscribers
keep alive time this time value tells the broker how often he should hear from the client before
considering him to be dead if publishing subscribing and updating is happening between
broker and client faster than to keep a lifetime then all is well if however for some reason
there is no activity between them then the brx plc will purposefully ping the broker at about
75 percent of this value to let him know that he is not dead if he does not do this and to keep
alive time expires the broker knowing this value will consider the client to have died
last will and testament now this is a funny term but it's appropriate for this use
this is a topic published to the broker to tell him essentially this if you haven't heard from me
within the keep a lifetime then consider me dead and send this particular topic to all those other
clients who are interested in my well-being if the client therefore dies subscribers will
get his last will and testament if the client disconnects gracefully that is he sends an mqtt
disconnect then the broker will delete his last will and testament without sending it to anyone
session type there are two kinds clean and persistent clean first let's say the connection
is disrupted and the client disappears the broker then deletes or cleans this client's subscriptions
when the connection is restored the client must re-subscribe to the topics that he's interested in
persistent means that he will not clean up after the client disappears so once again
let's say the connection is disrupted but this time the broker keeps the client's subscriptions
in other words the subscriptions persist and even cues up messages for the missing client
thus when the connection is restored the client does not
have to resubscribe and even receives any queued up messages
mqtt was introduced in do-more technology version 2.3 in june of 2018. it had no tls or
ssl encryption support only supported a qos of zero only a clean session type was allowed and
there was no user specified client id allowed and the only data that you could publish was text also
whatever was subscribed to was stored in text in the bricks this means if the data you needed was a
numeric you had to use other do-more instructions to convert it from a string to a numeric also
of course the mqtt pub and mqtt sub-instructions were added to facilitate using mqtt in a brix plc
version 2.52 came out in april of 2019. in this version tls and ssl encryption
was added also a qos 01 was supported and also a persistent session type was added
also two new instructions were added that can be useful when using mqtt the reason being many
times data you get from a topic comes back in the popular json data format so to aid
you in this data format both sending and receiving instructions json build for building your own data
in json format and json parse for interpreting data that you receive in this format were added
version 2.62 came out in august of 2019. this version changed the mqtt pub and mqttd
sub instructions so that they can send and receive numeric data instead of text only
version 2.74 came out in april of 2020. this added a tool for viewing json data in a pretty
format json data comes back in a single string yet it can have many nested topics or objects
viewing it as a single string is very difficult the new tool allows you to view the json data
string in such a way that it's easy to view and to pick out what you're interested in also
the client id that in previous versions was generated automatically by do-more
was now allowed to be user specified in a 64-byte string
this concludes the overview of mqtt for bricks to see how to avail its use in the briggs plc
check out our simple mqtt example video