# Victron Node-Red instance ... does anybody know how to use MQTT Broker?

**URL:** <https://discourse.nodered.org/t/victron-node-red-instance-does-anybody-know-how-to-use-mqtt-broker/90166>\
**Category:** General\
**Created:** [14 August 2024 07:16 UTC](https://discourse.nodered.org/t/victron-node-red-instance-does-anybody-know-how-to-use-mqtt-broker/90166 "2024-08-14T07:16:48Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Gawan](https://avatars.discourse-cdn.com/v4/letter/g/e9c0ed/32.png) [@Gawan](https://discourse.nodered.org/u/Gawan)\
**Post date:** [14 August 2024 07:16 UTC](https://discourse.nodered.org/t/victron-node-red-instance-does-anybody-know-how-to-use-mqtt-broker/90166/1 "2024-08-14T07:16:48Z")

</div>

Hi all,

I am using a Victron Cerbo device with integrated Node-Red instance (Venus OS Large).  
There is an integrated MQTT broker that works basically fine - I get all messages from Victron into my Node-Red instance using the prepared nodes.

BUT ... I want to send additional MQTT messages to this Cerbo MQTT broker but whatever I configure ... they to not show up if I check the broker with MQTT explorer.  
I tried different ports, username, QoS .... everything ... but still no message visible.

Does anybody know this issue and a possible workaround for it ?

BR  
Gawan

---

<div class="post-metadata">

**Author:** ![Trying\_to\_learn](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/trying_to_learn/32/28400_2.png) [@Trying\_to\_learn](https://discourse.nodered.org/u/Trying_to_learn)\
**Post date:** [14 August 2024 07:35 UTC](https://discourse.nodered.org/t/victron-node-red-instance-does-anybody-know-how-to-use-mqtt-broker/90166/2 "2024-08-14T07:35:19Z")

</div>

So sorry, explain to _me_ (aka _us_) what configuration you have in the MQTT nodes in Node-Red that receive the messages?

eg: the IP address, the topic.

Because - all here after as an example:  
You set up the broker's details in NR as:  
`192.168.0.1`  
Then you put a `MQTT IN` node and set that as the broker.  
You then enter `example` in the `topic` and you receive data. What ever that is.

So, you then get a `MQTT OUT` node, set it up with the broker - as before.  
Set it's `topic` to `another_example` and stick an `inject` node to that node.

Next, you get a `MQTT IN` node, set it to the broker and set it's topic to `another_example`.  
Connect a `debug` node to it.

DEPLOY it and then press the `inject` node, you should see the `debug` node display a _timestamp_ message each time you press the `inject` node.

---

<div class="post-metadata">

**Author:** ![no\_mpimpi](https://avatars.discourse-cdn.com/v4/letter/n/f14d63/32.png) [@no\_mpimpi](https://discourse.nodered.org/u/no_mpimpi)\
**Post date:** [14 August 2024 11:08 UTC](https://discourse.nodered.org/t/victron-node-red-instance-does-anybody-know-how-to-use-mqtt-broker/90166/3 "2024-08-14T11:08:35Z")

</div>

Hi @Gawan

I have a Victron Multiplus II. Using the onboard MQTT works, but there are a great many complications. You cannot connect it to your own broker, and you have to send it keepalive messages or it will die.

I have had a lot more success using modbus to connect to it. You will need to install nodered-contrib-modbus.

On the Victron website, you will find a spreadsheet with all of the modbus codes for every single victron variable you can think of, and two way communication is supported.

Here is an example in practise:

```auto
[{"id":"84f6edcbee42578f","type":"modbus-read","z":"cd7ae4ff9ca97a6d","name":"Grid status","topic":"/site/nest/util/inverter/data/grid/status","showStatusActivities":false,"logIOActivities":false,"showErrors":false,"showWarnings":true,"unitid":"242","dataType":"HoldingRegister","adr":"3","quantity":"1","rate":"5","rateUnit":"s","delayOnStart":false,"startDelayTime":"","server":"b93afde3.dea82","useIOFile":false,"ioFile":"","useIOForPayload":false,"emptyMsgOnFail":false,"x":460,"y":300,"wires":[["f9a6bed6fb53bb43"],[]]},{"id":"0852f6ea5fee1d22","type":"modbus-read","z":"cd7ae4ff9ca97a6d","name":"Battery level","topic":"","showStatusActivities":false,"logIOActivities":false,"showErrors":false,"showWarnings":true,"unitid":"242","dataType":"HoldingRegister","adr":"30","quantity":"1","rate":"5","rateUnit":"s","delayOnStart":false,"startDelayTime":"","server":"b93afde3.dea82","useIOFile":false,"ioFile":"","useIOForPayload":false,"emptyMsgOnFail":false,"x":460,"y":360,"wires":[["8ee9a46bd7d2488b"],[]]},{"id":"8ee9a46bd7d2488b","type":"function","z":"cd7ae4ff9ca97a6d","name":"Set Global Variables and MQTT topic","func":"var intmsg = parseInt(msg.payload)/10;\nmsg.payload = intmsg;\nmsg.topic = \"/site/nest/util/inverter/data/chargelevel/status\"\nglobal.set(\"BatteryCharge\", msg.payload);\nreturn msg;","outputs":1,"timeout":0,"noerr":0,"initialize":"","finalize":"","libs":[],"x":750,"y":360,"wires":[["49ae1df0d1b9dcce"]]},{"id":"689b707d9f6f94e6","type":"modbus-read","z":"cd7ae4ff9ca97a6d","name":"Charging Mode","topic":"","showStatusActivities":false,"logIOActivities":false,"showErrors":false,"showWarnings":true,"unitid":"242","dataType":"HoldingRegister","adr":"31","quantity":"1","rate":"60","rateUnit":"s","delayOnStart":false,"startDelayTime":"","server":"b93afde3.dea82","useIOFile":false,"ioFile":"","useIOForPayload":false,"emptyMsgOnFail":false,"x":470,"y":420,"wires":[["d246934891c1cca8"],[]]},{"id":"f9a6bed6fb53bb43","type":"function","z":"cd7ae4ff9ca97a6d","name":"Set Global Variables and MQTT topic","func":"var intmsg = parseInt(msg.payload);\nif (intmsg > 2000) {\n msg.payload = true;\n} else {\n msg.payload = false;\n};\nglobal.set(\"GridStatus\", msg.payload);\nmsg.topic = \"/site/nest/util/inverter/data/grid/status\";\nreturn msg;","outputs":1,"timeout":0,"noerr":0,"initialize":"","finalize":"","libs":[],"x":750,"y":300,"wires":[["49ae1df0d1b9dcce"]]},{"id":"d246934891c1cca8","type":"function","z":"cd7ae4ff9ca97a6d","name":"Set Global Variables and MQTT topic","func":"var intmsg = parseInt(msg.payload)/10;\nmsg.payload = intmsg;\nglobal.set(\"ChargeMode\", msg.payload);\nmsg.topic = \"/site/nest/util/inverter/data/chargemode/status/\"\nreturn msg;","outputs":1,"timeout":0,"noerr":0,"initialize":"","finalize":"","libs":[],"x":750,"y":420,"wires":[["49ae1df0d1b9dcce"]]},{"id":"30117dd816aec682","type":"modbus-read","z":"cd7ae4ff9ca97a6d","name":"Solar yield","topic":"","showStatusActivities":false,"logIOActivities":false,"showErrors":false,"showWarnings":true,"unitid":"100","dataType":"HoldingRegister","adr":"850","quantity":"1","rate":"5","rateUnit":"s","delayOnStart":false,"startDelayTime":"","server":"b93afde3.dea82","useIOFile":false,"ioFile":"","useIOForPayload":false,"emptyMsgOnFail":false,"x":450,"y":480,"wires":[["3ee615d3e50f17d9"],[]]},{"id":"3ee615d3e50f17d9","type":"function","z":"cd7ae4ff9ca97a6d","name":"Set Global Variables and MQTT topic","func":"var intmsg = parseInt(msg.payload);\nmsg.payload = intmsg;\nglobal.set(\"SolarYield\", msg.payload);\nmsg.topic = \"/site/nest/util/inverter/data/solaryield/status/\";\nreturn msg;","outputs":1,"timeout":0,"noerr":0,"initialize":"","finalize":"","libs":[],"x":770,"y":480,"wires":[["49ae1df0d1b9dcce"]]},{"id":"49ae1df0d1b9dcce","type":"mqtt out","z":"cd7ae4ff9ca97a6d","name":"","topic":"","qos":"","retain":"","respTopic":"","contentType":"","userProps":"","correl":"","expiry":"","broker":"","x":1120,"y":380,"wires":[]},{"id":"b93afde3.dea82","type":"modbus-client","name":"System","clienttype":"tcp","bufferCommands":true,"stateLogEnabled":false,"queueLogEnabled":false,"failureLogEnabled":false,"tcpHost":"192.168.1.32","tcpPort":"502","tcpType":"DEFAULT","serialPort":"/dev/ttyUSB","serialType":"RTU-BUFFERD","serialBaudrate":"9600","serialDatabits":"8","serialStopbits":"1","serialParity":"none","serialConnectionDelay":"100","serialAsciiResponseStartDelimiter":"","unit_id":"242","commandDelay":"1","clientTimeout":"1000","reconnectOnTimeout":true,"reconnectTimeout":"2000","parallelUnitIdsAllowed":true,"showErrors":false,"showWarnings":true,"showLogs":true}]

```

You can see that after we get the data from the modbus node, we can easily add a topic, even just with a Change node. I'm using that data elsewhere in other functions, so I push it to a global context as well.

After you have added a topic, you just send it to an MQTT out node to publish it, and then listen to your MQTT in accordingly.

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/1X/d073cd938eafa2e558d7c2cd59003b3ef4963033.png) [@system](https://discourse.nodered.org/u/system)\
**Post date:** [12 November 2024 11:08 UTC](https://discourse.nodered.org/t/victron-node-red-instance-does-anybody-know-how-to-use-mqtt-broker/90166/4 "2024-11-12T11:08:44Z")

</div>

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.
