Node Red AEDES MQTT Broker Question

Hello! I am trying to make an escape room bomb prop, similar to what Alastair Aitchison created in this video: Google Search

Since this video was created in 2020, the issue I am running into is that the original Node Red MQTT server node that came with his sample .json file is obsolete (running MOSCA?) and will not connect to my chip (WEMOS D1 Mini). I disabled that node and downloaded the AEDES MQTT Broker instead. It says "connected" and the serial output on my Arduino IDE ways my D1 Mini is also connected to MQTT broker. However, when the MQTT payload is sent (word "BOOM"), this is what my AEDES debug node shows:

image

I am running through a cheap router with a local IP of 192.168.10.2, which my laptop and the D1 mini are both communicating through.

The AEDES debug note receives a message as this pops up at the same time the WEMOS message is sent, but the actual message (BOOM) does not seem to be coming through. The message "BOOM" does come through to Mosquitto as I have that up and running on my laptop, listening to the same topic, so I know the D1 mini is at least getting the message to Mosquitto on my laptop.

This is my first month in Node Red, so sorry for being a noob. I have run out of other ideas. Let me know if anyone needs to see source code or other settings. Images of my flow below if that helps. Thanks in advance!

Jeff

Just install Mosquitto, it is simple to install and configure, and absolutely reliable.

2 Likes

Completely agree. And it should be far more performant as well.

Just remember to add a Mosquitto config to allow connection from your IoT devices - there was another thread along those lines very recently.

As far as I know, Aedes broker does work but it's rather limited.

As @Colin says though, if you can install mosquitto, do so (You don't say what hardware Node-red is running on) because it is stable and utterly reliable.

NB
If you click on the little arrow next to "packet" you might find "BOOM" is in there somewhere.
Also change the debug to show the entire message object, in case its in msg.somethingelse.

Normally, a D1 mini would be setup to just connect to one broker.

It does that by being configured to connect to one ip and one port number (normally 1883)

If you are running both Mosquitto and the Aedes broker, I easily see that the mosquitto broker might be getting hold of port 1883 when you start your laptop up (that's what happens with a default Mosquitto installation)

So, when NodeRED starts and it tries to launch Aedes, Aedes will probably fail as it defaults to using port 1883 as well.

To test this out, change the port number that Aedes uses to 1884 and alter the code in the D1 mini to use port 1884 as well and see what happens

Colin, can you explain more? I have mosquito running on my laptop. Do you mean mosquito in node red?

He means, just run Mosquitto on the same device as Node-RED and configure your devices to talk to it directly. Ditch Aedes, it is a bit of a beast and not necessary.

Thanks for the quick notes all! To be clear, I am running mosquitto and Node Red both on my laptop simultaneously. Perhaps they are not communicating?

If I ditch the AEDES, will the Mosquitto from my laptop be picked up by my MQTT receiver within node red?

Cymplecy, I changed the AEDES and D1 mini both to 1884. Here is the incoming message (with details). Don't think I found the "BOOM" string, but it did input into the troubleshooting node at the same time the D1 mini timer hit zero and sent the message...

Let me know if I need to expand any more of these line items. Thanks again for the input everyone! I am enjoying the learning experience!

Here is what my Node-Red prompt is showing in its current configuration.
image

Well you are receiving a message. Presumably it originates at the microcontroller.

It looks a bit odd to have a property msg.payload.packet.payload And it's a buffer. 4 of whatever a buffer is though - bytes?

What firmware does the microcontroller run - Arduino code?
What structure do you expect msg.topic and msg.payload to have?
What input to the microcontroller triggers the explosion - could you switch to an alternative firmware?

Thanks Budd - Major breakthrough (and probably brain fart on my end). I changed the AEDES to port 1884 and ALSO the MQTT receiver node to 1884 (I had left it at 1883) and it worked!?

Here is the debug AEDES code received:

I don't see "BOOM" in this received code anywhere, but it definitely triggered the output.

So what someone can still educate me about is if mosquitto on my laptop is doing anything in this situation? Do I even need mosquitto operating, or would node red talk directly to the WEMOS D1 without mosquitto? (Sorry if this is a dumb question, I'm an EE, not a comp sci guy. Coding isn't my specialty, but if anyone needs some lighting design work done, I'm in :slight_smile: )

And ...


BOOM!

It does not matter how many MQTT brokers are running on your network, so long as no two are on the same combination of IP and port.

The only one that matters is the one your Wemos publishes to and Node-red subscribes to.

You do need a broker though, the Wemos cannot sent MQTT packets directly to Node-red. Aedes is one broker, Mosquitto is another, better one.

Have you tried adjusting the mqtt-in node config - perhaps tell it to expect a string?

lol, excellent! Haven't done ASCI since college "2001"

With the AEDES broker seemingly working, I'm going to take that as a win. So I am receiving what I need from the WEMOS back to Node Red. I am 99% done! The last step is to be able to send a "RESET" message back into the WEMOS from Node-Red to remotely reset the prop. Below is a screenshot of my Arduino IDE code (2.3.4) that is waiting for a MQTT topic of "RESET".

When I try to send a message back through an inject node, I am not receiving any message back on the WEMOS.

I thought that I could dump anything in under the topic "RESET" and it would be received by the WEMOS. Is there another setting to push back content the other direction? The node MQTT out still needs to point to the local host, correct (and not the IP of the WEMOS?)

You publish a message to the broker using msg.topic..
The Wemos has to subscribe to that identical topic on the broker.
(The broker is a general purpose server, it may have very many devices publishing and subscribing)

The topic "RESET" might be correct but more usually it would have an indication of the device it's intended for eg "wemos/1/reset"

Thanks J, that makes sense. In my Arduino code, the deivce is (arbitrarily called "100" per the image below.
image

Where do I place the ID of the target device within Node Red? This field?

I appreciate your help budd

No.

Read this/watch the videos: All you need to know about MQTT

These links and videos are good info! I think I am understanding the publish/subscribe concept. What I am still not understanding is what I need to change in my Arduino code to subscribe back to the AEDES broker. I thought the code line of if(Strstr(topic, "RESET")... was setting up my WEMOS to subscribe to that topic, so if any message came in with that topic, it would trigger the "Activate" function. So when I try to send a MQTT message back with that topic, I thought it would be received by the WEMOS. Am I missing additional code to point to the AEDES broker specifically? I am pointed to port 1884, which is where Node Red is running. Thanks JB!