MQTT publish MQTT
Sends Source to the publish tag's topic when the rung turns on.
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
| Operand | Data type | Read or write |
|---|---|---|
| MQTT tag | MQTT | Reads and writes |
| Source | BOOL, SINT, INT, DINT, LINT, REAL, STRING, CHAR or a number | Reads |
| Dest | BOOL, DINT, REAL, STRING | Writes |
Inside a MQTT tag
| Member | Type | Meaning |
|---|---|---|
| .EN | BOOL | Read only |
| .BSY | BOOL | Read only |
| .DN | BOOL | Read only |
| .ER | BOOL | Read only |
| .ErrorText | STRING | Read 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.