Makers Blog Archive

How to create a simple MQTT broker on the AXC F 2152 with Node-Red

mschneider 20 February 2019 min. read
349 views 0 comments

Here is a method to create and test a simple MQTT broker on the AXC F 2152 / Node-Red.

Goto the Node-Red menu (the 3 lines, at the right of the screen) and select ‘Manage Palette’.

Go to the Install tab, and type ‘mqtt’ in the ‘search modules’ line

There, select ‘node-red-contrib-mqtt-broker’ and clic on ‘install’.


Then, after a while, you will see this icon in the input menu of Node-Red :


Drag and drop this item in a flow, and then, parameterize it :

Just define the MQTT ports, and a user with a password :


To make a test, and publish some datas, you have to use the native MQTT items from Node-Red.


To publish a data, just insert the MQTT output, and use the local MQTT broker that you just created :


Create the link to the local MQTT broker : (Server IP, Name, Username and Password are important)


Generate a variable wich will be published to the MQTT broker : (here, the timestamp will be the value of ‘test’ :


‘test’ will be the name of the variable accessible in the MQTT broker

Then, you have to subscribe to this variable, so that you are aware when it is modified :

So, insert the input MQTT, and define the parameters as follow :


When this is made, deploy your flow, and it should be like that :


If you trigger the test:timestamp input, then you should see the result in the debug window :


Here is the flow code :

[{“id”:”4016a1db.9eded”,”type”:”tab”,”label”:”Local MQTT Broker”,”disabled”:false,”info”:””},{“id”:”2687b84b.c8a488″,”type”:”debug”,”z”:”4016a1db.9eded”,”name”:””,”active”:true,”tosidebar”:true,”console”:false,”tostatus”:false,”complete”:”false”,”x”:370,”y”:80,”wires”:[]},{“id”:”aaa1e303.ff17d”,”type”:”mosca in”,”z”:”4016a1db.9eded”,”mqtt_port”:1883,”mqtt_ws_port”:8080,”name”:””,”username”:”admin”,”password”:”taratata”,”dburl”:””,”x”:130,”y”:80,”wires”:[[“2687b84b.c8a488”]]},{“id”:”af0f4b2b.3fa4d8″,”type”:”inject”,”z”:”4016a1db.9eded”,”name”:””,”topic”:”test”,”payload”:””,”payloadType”:”date”,”repeat”:””,”crontab”:””,”once”:false,”onceDelay”:0.1,”x”:120,”y”:180,”wires”:[[“7445890e.85ca98”]]},{“id”:”abe24f4d.038f”,”type”:”mqtt in”,”z”:”4016a1db.9eded”,”name”:””,”topic”:”test”,”qos”:”2″,”broker”:”e5edf71d.49dd18″,”x”:90,”y”:280,”wires”:[[“cdc20322.c5eda”]]},{“id”:”cdc20322.c5eda”,”type”:”debug”,”z”:”4016a1db.9eded”,”name”:””,”active”:true,”tosidebar”:true,”console”:false,”tostatus”:false,”complete”:”false”,”x”:288,”y”:280,”wires”:[]},{“id”:”7445890e.85ca98″,”type”:”mqtt out”,”z”:”4016a1db.9eded”,”name”:””,”topic”:””,”qos”:””,”retain”:””,”broker”:”e5edf71d.49dd18″,”x”:360,”y”:180,”wires”:[]},{“id”:”e5edf71d.49dd18″,”type”:”mqtt-broker”,”z”:””,”name”:”local”,”broker”:”″,”port”:”1883″,”clientid”:””,”usetls”:false,”compatmode”:true,”keepalive”:”60″,”cleansession”:true,”birthTopic”:””,”birthQos”:”0″,”birthPayload”:””,”closeTopic”:””,”closeQos”:”0″,”closePayload”:””,”willTopic”:””,”willQos”:”0″,”willPayload”:””}]


The Makers Blog shows applications and user stories of community members that are not tested or reviewed by Phoenix Contact. Use them at your own risk.


Please login/register to comment


Leave a Reply

Never miss a new article
Sign up for the newsletter
Never miss news about PLCnext Technology
Get interesting content via newsletter four times a year
Receive exclusive information before all other users