# Node Red AEDES MQTT Broker Question

**URL:** <https://discourse.nodered.org/t/node-red-aedes-mqtt-broker-question/95733>\
**Category:** General\
**Tags:** mqtt\
**Created:** [1 March 2025 17:09 UTC](https://discourse.nodered.org/t/node-red-aedes-mqtt-broker-question/95733 "2025-03-01T17:09:13Z")\
**Posts on this page:** 7\
**Page:** 2

<div class="post-metadata">

**Author:** ![jbudd](https://avatars.discourse-cdn.com/v4/letter/j/5f8ce5/32.png) [@jbudd](https://discourse.nodered.org/u/jbudd)\
**Post date:** [3 March 2025 02:26 UTC](https://discourse.nodered.org/t/node-red-aedes-mqtt-broker-question/95733/21 "2025-03-03T02:26:03Z")

</div>

I am not sure that you are fully grasping the publish/subscribe approach.

Somewhere in the Arduino code you need to have a `subscribe` command.  
We don't know what mqtt library you are using but the syntax might be something like

```auto
mqtt.subscribe("RESET")

```

This line notifies the broker which topic your code is interested in. The broker will send _nothing_ to the Wemos without this.

But this is a Node-red forum, I'm sure you would get more help if you can find a support forum for the Arduino IDE, or there are plenty of online examples for MQTT on Arduino.

---

<div class="post-metadata">

**Author:** ![Jeffro](https://avatars.discourse-cdn.com/v4/letter/j/7993a0/32.png) [@Jeffro](https://discourse.nodered.org/u/Jeffro)\
**Post date:** [3 March 2025 03:15 UTC](https://discourse.nodered.org/t/node-red-aedes-mqtt-broker-question/95733/22 "2025-03-03T03:15:27Z")

</div>

Good point, I'll see what I can dig up on an Arduino forum. Thanks again!

---

<div class="post-metadata">

**Author:** ![dynamicdave](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/dynamicdave/32/96_2.png) [@dynamicdave](https://discourse.nodered.org/u/dynamicdave)\
**Post date:** [3 March 2025 07:33 UTC](https://discourse.nodered.org/t/node-red-aedes-mqtt-broker-question/95733/23 "2025-03-03T07:33:40Z")

</div>

Here's the Arduino code I used to test using the remote HiveHQ broker in a very old Wemos D1 Mini device (I no longer use). You will need to adjust the settings to match your local situation.

```auto
#include <WiFi.h> // Use <ESP8266WiFi.h> for ESP8266
#include <PubSubClient.h>

const char* ssid = "Your_WiFi_SSID";
const char* password = "Your_WiFi_Password";
const char* mqtt_server = "broker.hivemq.com"; // Public MQTT broker

WiFiClient espClient;
PubSubClient client(espClient);

void callback(char* topic, byte* payload, unsigned int length) {
  Serial.print("Message arrived [");
  Serial.print(topic);
  Serial.print("]: ");
  
  for (unsigned int i = 0; i < length; i++) {
    Serial.print((char)payload[i]);
  }
  Serial.println();
}

void setup() {
  Serial.begin(115200);
  
  // Connect to Wi-Fi
  WiFi.begin(ssid, password);
  while (WiFi.status() != WL_CONNECTED) {
    delay(500);
    Serial.print(".");
  }
  Serial.println("\nWiFi connected");

  // Setup MQTT
  client.setServer(mqtt_server, 1883);
  client.setCallback(callback);

  // Connect to MQTT Broker
  while (!client.connected()) {
    Serial.print("Connecting to MQTT...");
    if (client.connect("ESPClient")) {
      Serial.println("connected");
      client.subscribe("test/topic"); // Subscribe to topic
    } else {
      Serial.print("failed, rc=");
      Serial.print(client.state());
      Serial.println(" retrying in 5 seconds...");
      delay(5000);
    }
  }
}

void loop() {
  client.loop(); // Keep MQTT connection alive
}

```

Notice there is a **client.subscribe("test/topic");** about 12-lines from the bottom of the script.

---

<div class="post-metadata">

**Author:** ![dynamicdave](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/dynamicdave/32/96_2.png) [@dynamicdave](https://discourse.nodered.org/u/dynamicdave)\
**Post date:** [3 March 2025 08:56 UTC](https://discourse.nodered.org/t/node-red-aedes-mqtt-broker-question/95733/24 "2025-03-03T08:56:29Z")

</div>

Here's a link to one of my IoT students' project controlling some LEDs via a local MQTT broker.  
Although the project is over 3-years old it should still work.  
Hope it helps you get started with using MQTT as a transport medium.

> [@Controlling LEDs on a Wemos D1 Mini (Arduino code) via MQTT](https://discourse.nodered.org/t/controlling-leds-on-a-wemos-d1-mini-arduino-code-via-mqtt/62523):
>
> One of my IoT students was asking how to control a set of LEDs on a Wemos D1 Mini, that had been programmed using Arduino code, via MQTT commands from Node-RED. This is what the breadboard lash-up looks like... The red LED is connected to D8 (GPIO-15). The green LED is connected to D7 (GPIO-13) The yellow LED is connected to D6 (GPIO-12) This is the very simple test-flow we created in Node-RED. [Screen Shot 05-11-22 at 06.35 PM] [{"id":"bb2bbcc236726f09","type":"tab","label…

---

<div class="post-metadata">

**Author:** ![Jeffro](https://avatars.discourse-cdn.com/v4/letter/j/7993a0/32.png) [@Jeffro](https://discourse.nodered.org/u/Jeffro)\
**Post date:** [5 March 2025 01:19 UTC](https://discourse.nodered.org/t/node-red-aedes-mqtt-broker-question/95733/25 "2025-03-05T01:19:45Z")

</div>

Thanks for the info Dave! I will do some studying of this code and see if I can't get my Arduino code receiving AEDES broker info. Appreciate it!!

---

<div class="post-metadata">

**Author:** ![dynamicdave](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/dynamicdave/32/96_2.png) [@dynamicdave](https://discourse.nodered.org/u/dynamicdave)\
**Post date:** [5 March 2025 06:11 UTC](https://discourse.nodered.org/t/node-red-aedes-mqtt-broker-question/95733/26 "2025-03-05T06:11:13Z")

</div>

Note: I think most people, on the Node-RED forum, use the Mosquitto broker rather than ADES.

I must admit, I've not used Arduino or Wemos D1 Mini devices for a few years as I switched over to using ESP32-S2-Mini (or ESP32-C3-Super-Mini) and Micro-Python for my personal projects.

During COVID I was trying to clean-up over 50 Wemos devices my IoT students had used. Some of the devices had been flashed with Arduino and some with ESPeasy, so (in a lot of cases) when I powered-them-up it was impossible to find out what was coded onto them. Micro-Python is an interperted language written in plain text that is loaded onto the microcontroller. So when it is connected to a terminal or PC you can "see" (and edit) the code inside it. So easy to maintain.

The ESP32-S2-Mini is built using a newer technology with higher performance, much faster than the Wemos and offers a lot more functionality. Although it has twice as many pins as the Wemos, it is pin-compatible on the outer column of pins, so can be used as a drop-in replacement.

I intend to explain my rationale in more detail as a write-up on 'Share Your Projects' (soon).

---

<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:** [3 June 2025 06:11 UTC](https://discourse.nodered.org/t/node-red-aedes-mqtt-broker-question/95733/27 "2025-06-03T06:11:38Z")

</div>

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

[Previous page](https://discourse.nodered.org/t/node-red-aedes-mqtt-broker-question/95733.md?page=1)
