MQTT publish MQTT

Sends Source to the publish tag's topic when the rung turns on.

Messages go from the broker to the Connection Service on this computer, then into your project as Link tags. MQTT Publish sends values the other way.MQTT brokerlocalhost : 1883factory/line1/tempfactory/line1/countConnection ServiceOn this computer. Keeps the password.Your projectReadIO::MyBroker.Mqtt.TempSendMQTT Publish → CountMQTTmessages inpublish out

How it works

.DN and .ER stay on until the rung goes from false to true again. Holding the rung true does not send again.

In practice

MQTT Publish works like a Move. Each time the rung goes from false to true, it copies Source into Destination and sends it to the Destination's topic as plain text, like 1520 or true.

Configuration

  • Tag: an MQTT tag. It holds the status bits .EN, .BSY, .DN, .ER and .ErrorText.
  • Source: a PLC tag or a number, for example Global.PartCount.
  • Destination: a publish tag on the Link, for example CountMQTT. Its topic is where the message goes.

Limits and status

  • .EN is on while the rung is true. .BSY is on while the message is being sent. .DN is on when the broker has the message. .ER is on if the message was not sent, and .ErrorText says why.
  • The broker confirms every message. If it does not answer, .ER turns on.

Operands

OperandData typeRead or write
MQTT tagMQTTReads and writes
SourceBOOL, SINT, INT, DINT, LINT, REAL, STRING, CHAR or a numberReads
DestBOOL, DINT, REAL, STRINGWrites

Inside a MQTT tag

MemberTypeMeaning
.ENBOOLRead only
.BSYBOOLRead only
.DNBOOLRead only
.ERBOOLRead only
.ErrorTextSTRINGRead only

Common mistakes

  • Holding the rung true to send repeatedlyPublish starts on a false-to-true transition. Read DN, ER and ErrorText before triggering another message.