How to connect node-red with mqtt broker

  1. Where did you got the topic command///req/# from?
    Hint: It is nonsense.
  2. Why does it have repeated / characters?
  3. Do you know the special meanings of # and + in mqtt topics?
    If not, you need to do some reading about mqtt. I don't know your native language so I cannot recommend suitable material.
  4. What do you expect that a message published to command///req/# will do?
    You cannot publish to a wildcard topic.

can you provide me examples of mqtt and test nodes (server, topic, connection and security) details.

[quote="Naveen, post:46, topic:82207"]

Yes of course. I have an mqtt broker running on a Raspberry Pi at 192.168.1.11. It is Mosquitto.

I have to use a username and password to connect to it. My username is jbudd and my password is Password1.

In this simple flow the inject node sets msg.payload "Hello" and msg.topic "test".
The mqtt-out node accepts the topic from msg.topic.
The mqtt-in node subscribes to topic "test".
For more complicated setups I might use a topic like reactor1/coretemperature or reactor1/radiation
image

So that's my setup. Since I have no idea what your setup is like you might find you need different settings.
But since your mqtt node is Connected, all you need is a sensible topic

Please note @Naveen , if you ignore my questions again I will not try and help you in future.

1 Like

The flow you posted above looks nothing like the Test-Flow I posted as item-23 of this thread.

Are you sure you 'imported' the Node-RED flow and tried it out as it should work without any problems with the test-server at Eclipse?? I suggest you get the basic flow working before getting more complicated.

eclipse

Here is the basic flow again, I assume you know how to 'import' the Node-RED flow from here?

[{"id":"a4261bec1cbf0778","type":"tab","label":"Flow 39","disabled":false,"info":"","env":[]},{"id":"1678825c5d940452","type":"mqtt in","z":"a4261bec1cbf0778","name":"","topic":"test","qos":"2","datatype":"auto-detect","broker":"2d2f5234db1e57bd","nl":false,"rap":true,"rh":0,"inputs":0,"x":150,"y":220,"wires":[["9ef778879f8ca7c5"]]},{"id":"981d13a9a47220e3","type":"mqtt out","z":"a4261bec1cbf0778","name":"","topic":"test","qos":"","retain":"","respTopic":"","contentType":"","userProps":"","correl":"","expiry":"","broker":"2d2f5234db1e57bd","x":330,"y":140,"wires":[]},{"id":"e553550126382b67","type":"inject","z":"a4261bec1cbf0778","name":"","props":[{"p":"payload"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"Hello World","payloadType":"str","x":170,"y":140,"wires":[["981d13a9a47220e3"]]},{"id":"9ef778879f8ca7c5","type":"debug","z":"a4261bec1cbf0778","name":"repsonse","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":340,"y":220,"wires":[]},{"id":"2d2f5234db1e57bd","type":"mqtt-broker","name":"Eclipse","broker":"test.mosquitto.org","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":""}]

Hii, i'm using this topic in mqtt broker, it's not the issue with this topic, i have connected mqtt broker with node-red, i'm able to receive the command & control messages in the node-red.

So if you are now able to connect, is the problem solved?

yes, it's solved but i have a doubt that how to connect and emit the device in node-red

yes i tried, it's working fine.
Thanks

So since you say you have got my test flow working your next step is to sort out your own MQTT broker.

You can either install a local broker on your Raspberry Pi (e.g. Mosquitto) or sign-up with a remote broker.
There are a number of companies that offer a "free-tier" - one of them (that I use) is BeeBotte.
The choice will depend on the location (local or remote) of where your data originates.

1 Like

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