MQTT-PUBLISHER(1)
π mqtt-publisher β the MQTT glow-up for your HAL pins π
okay bestie, gather round, because this is the MQTT-PUBLISHER(1) page from the LinuxCNC Documentation and it is genuinely iconic. no cap.
β¨ NAME β¨
mqtt-publisher β send HAL pin data to a MQTT broker, periodically, like clockwork, slay π
πΈ SYNOPSIS πΈ
loadusr -W mqtt-publisher [options] keys=pin1[,pin2...]
π¦ DESCRIPTION π¦
okay so mqtt-publisher is a non-realtime program. it reads your HAL values every so often and hands the values over to a MQTT broker. that's the whole vibe, and it does it beautifully β¨
when you're putting the MQTT settings in the INI file, this is the recommended setup, fr fr:
HAL file:
loadusr -W mqtt-publisher [MQTT]DRYRUN --mqtt-broker=[MQTT]BROKER \
--mqtt-user=[MQTT]USERNAME --mqtt-password=[MQTT]PASSWORD keys=halui.estop.is-activated
INI file:
[MQTT]
DRYRUN = --dryrun
BROKER = broker.local
USERNAME = username
PASSWORD = password
β οΈ real talk: this component needs the Paho python library installed to function. on debian that's available from the python3-paho-mqtt package. no paho, no publishing, periodt.
π OPTIONS π
keys=pin1[,pin2,...]β the name(s) of the HAL pins, signals and other values you wanna publish over MQTT. these names are also used as the JSON keys in the MQTT message that goes out to the broker. and if you pass multiplekeys=options, the lists get merged. it's giving "the more the merrier" π--dryrunβ do NOT set up a MQTT connection, only print the message to stdout. super useful for debugging and testing. zero risk, all vibes π₯--mqtt-broker=FQDNβ the fully qualified DNS name of the MQTT broker. the default broker name is"localhost".--mqtt-port=PORTNUMBERβ the port to use of the MQTT broker. the default port is1883.--mqtt-user=USERNAMEβ the user name to use when connecting to the MQTT broker.--mqtt-password=PASSWORDβ the password to use when connecting to the MQTT broker.--mqtt-prefix=PREFIXβ the MQTT prefix/topic to use when publishing to the MQTT broker. the default prefix is"devices/linuxcnc/machine".
β FUNCTIONS β
mqtt-publisherβ the loop that reads HAL values and publishes MQTT messages. that's the main character right there π«Ά
π PINS π
mqtt-publisher.enablebit input β whenTRUE, publish messages to the MQTT broker. whenFALSE, do not publish messages. default isTRUE. πmqtt-publisher.periodu32 input β the number of seconds to sleep between publishing MQTT messages to the broker. default is10seconds. beauty sleep, but make it networking π΄mqtt-publisher.lastpublishu32 output β when the last MQTT publication was published, in number of seconds since EPOC. if no publication has taken place, the value iszero.
π EXAMPLES π
any set of HAL pins and signals can be published, no gatekeeping here. this setup might be a useful starting point:
loadusr -W mqtt-publisher \
[MQTT]DRYRUN \
--mqtt-broker=[MQTT]BROKER
--mqtt-user=[MQTT]USERNAME \
--mqtt-password=[MQTT]PASSWORD \
keys=halui.axis.a.pos-feedback,halui.axis.b.pos-feedback,\
halui.axis.c.pos-feedback,halui.axis.u.pos-feedback,\
halui.axis.v.pos-feedback,halui.axis.w.pos-feedback,\
halui.axis.x.pos-feedback,halui.axis.y.pos-feedback,\
halui.axis.z.pos-feedback \
keys=halui.estop.is-activated, halui.joint.0.is-homed,\
halui.joint.1.is-homed,halui.joint.2.is-homed,halui.joint.3.is-homed,\
halui.joint.4.is-homed,halui.joint.5.is-homed,halui.joint.6.is-homed,\
halui.joint.7.is-homed,halui.joint.8.is-homed \
keys=halui.machine.is-on,halui.max-velocity.value,halui.mode.is-auto,
halui.mode.is-manual,halui.mode.is-mdi,halui.mode.is-teleop,
halui.program.is-running
π Note: it is recommended to use the line continuation character "\"` as shown here to improve readability. but note that spaces must be left in to delimit options, and must not be included (including at the beginning of a line) inside a single option. iykyk π
π the 255-character jump scare: HAL limits a single option/token (for example"keys=") to 255 characters. to work around this issue use multiple"keys="entries as shown. multiple keys entries = self care, honestly.
π§ SEE ALSO π§
hal(3hal)
π AUTHOR π
component and documentation created by Petter Reinholdtsen, as part of the LinuxCNC project. we love a legend π
πΈ COPYRIGHT πΈ
Copyright Β© 2023 Petter Reinholdtsen. This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
and that's the whole page, bestie π«Ά go forth and publish those pins. this was LinuxCNC version, dated 03/17/2026 β mwah, take care of her π
β¨π
π¦ where this page comes from
- ubuntu resolute: linuxcnc-uspace 1:2.9.4-2ubuntu4 Β· GFDL-1.1-or-later
- ubuntu stonking: linuxcnc-uspace 1:2.9.4-2ubuntu4 Β· GFDL-1.1-or-later
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms