Why cant I see any MQTT messages on debug node

image

I wont say I am new to node red but I am quite inexperienced despite me being an embedded engineer I have manage to get some simple node-red stuff to work, I am looking for help on how to achieve the outcome but have failed so far so I am asking on here if anyone can point me in the right direction with MQTT and the first step of being able to see some data on a debug node. surely this is possible right? I have used MQTT Explorer on my MQTT broker (solar assistant) so know it works, I can see the broker is also connected on node red and has a green indicator, but nothing being display by the debug node at all, how do I see the data in the debug node please?

Many thanks in advance for you help

Welcome to the forums @Picmon

I'm not overly experienced with MQTT.

But my first thought is - have you subscribed to the correct topic in the Node?
can you provide your topic?

Indeed, as Marcus suggests, I guess the topic is the issue. This page has some information on setting it and also mentions wildcards. You could just use # to get output from all topics and use that to test:
https://cookbook.nodered.org/mqtt/subscribe-to-topic

1 Like

Thanks for your reply Marcus, how would one know what topic to subscribe to, is the a way for finding out? what topics are available?, not sure what the definition of a topic is but guessing is one of the above such as state_of_charge, how would I be able to display this in the debug node please?

Double click the node in your flow - and you can set a topic.

image

or use # as a wildcard

MQTT Messages are addressed to a Topic.

Exampels of MQTT topics

  • familyroom/lights/main
  • familyroom/lights/table

Here's a very simple test flow for a local MQTT broker (it uses the topic: test)
test_mqtt

[{"id":"82cbe9a3221a369b","type":"inject","z":"0e90d9248cf5a9ce","name":"","props":[{"p":"payload"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"Hello world","payloadType":"str","x":260,"y":200,"wires":[["fb0ee3e59c1f0826"]]},{"id":"f90c59804fd08621","type":"debug","z":"0e90d9248cf5a9ce","name":"debug message","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":480,"y":260,"wires":[]},{"id":"2370f7c230b79c2f","type":"mqtt in","z":"0e90d9248cf5a9ce","name":"","topic":"test","qos":"2","datatype":"auto-detect","broker":"846a8c23e24a78db","nl":false,"rap":true,"rh":0,"inputs":0,"x":230,"y":260,"wires":[["f90c59804fd08621"]]},{"id":"fb0ee3e59c1f0826","type":"mqtt out","z":"0e90d9248cf5a9ce","name":"Local MQTT broker","topic":"test","qos":"","retain":"","respTopic":"","contentType":"","userProps":"","correl":"","expiry":"","broker":"846a8c23e24a78db","x":470,"y":200,"wires":[]},{"id":"cbb6c83fa987e42b","type":"comment","z":"0e90d9248cf5a9ce","name":"A very basic test to check your local MQTT broker","info":"","x":370,"y":140,"wires":[]},{"id":"846a8c23e24a78db","type":"mqtt-broker","name":"","broker":"127.0.0.1","port":"1883","clientid":"","autoConnect":true,"usetls":false,"protocolVersion":"4","keepalive":"60","cleansession":true,"autoUnsubscribe":true,"birthTopic":"","birthQos":"0","birthRetain":"false","birthPayload":"","birthMsg":{},"closeTopic":"","closeQos":"0","closeRetain":"false","closePayload":"","closeMsg":{},"willTopic":"","willQos":"0","willRetain":"false","willPayload":"","willMsg":{},"userProps":"","sessionExpiry":""}]

Using MQTT Explorer you should be able to see the topic-structure.


So in this example I could subscribe to: homeDevice or homeDevice/reading/node42

The picture of your little flow shows an input on your mqtt-in node which means you have it set up for dynamic subscription.

Dynamic subscription mode can be very useful but usually it's better to specify the topic in the node config, perhaps using wildcards to subscribe to a group of related topics.

2 Likes

Thanks to everyone for all your help I can now see data now

2 Likes

If you are just starting with MQTT then this guide should prove very helpful: MQTT Essentials - All Core Concepts Explained

1 Like

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