The EQSP32 PLC, beyond its rich set of high-density I/Os and industrial peripherals, provides extensive integration options with a wide range of systems and platforms.
In this article, we will explore how to design automation solutions by combining the EQSP32 IoT controller with Node-RED using the MQTT protocol—enabling you to build robust, visual automation systems for industrial and commercial applications.
Overview of EQSP32 PLC integration with Node-RED.
Preparing Node-RED and dashboard.
Developing the EQSP32 integration.
Testing the MQTT connection on EQSP32 side.
Deploy and verify real-time operation of final UI.
With EQSP32, you get the flexibility of an open PLC to build custom integrations, combined with the power and simplicity of its embedded features—allowing you to focus on your application while avoiding the usual complexity and overhead of IoT connectivity.
This powerful combination allows you to monitor sensors and control outputs with minimal code, leveraging EQSP32’s built-in support for MQTT topic generation and interfacing.
Whether you’re designing a smart factory dashboard or prototyping a building automation system, this guide will show you how to:
- Create interfacing entities to publish sensor data and receive control commands over MQTT topics
- Control relays and monitor sensors using Node-RED dashboards and logic flows
- Skip manual broker configuration, topic parsing, and payload handling—thanks to EQSP32’s self-managed MQTT stack and easy-to-use API
By the end of this tutorial, you’ll have a live Node-RED dashboard fully connected to your EQSP32, displaying real-time sensor readings and driving outputs via MQTT.
Overview of EQSP32 PLC integration with Node-RED
The EQSP32 PLC is designed to both operate as a standalone automation controller and seamlessly connect field devices, sensors, and actuators with higher-level automation platforms. Its rich I/Os handle real-world signals, while its embedded IoT functionality makes data exchange simple and reliable. When combined with Node-RED, users can quickly build interactive dashboards, automation flows, and integrations with other systems.
Where is Node-RED deployed
Node-RED is a flow-based programming environment that runs on a wide range of platforms:
- Local PC or Laptop (Windows, Linux, macOS) for development and testing.
- Raspberry Pi or Industrial Edge PCs for edge automation.
- Cloud Platforms (e.g., FlowFuse, IBM Cloud) for remote dashboards and global monitoring.

How EQSP32 interacts with its environment
- Inputs: Digital (DIN), analog (AIN/RAIN), current input (CIN), temperature inputs (TIN), and more, capture real-world signals such as switches, voltage levels, 4-20mA sensors, counters, and NTC sensors.
- Outputs: Relay (RELAY) and power outputs (POUT) drive external loads including relays, solenoid valves, LEDs, and other actuators.
- Processing: EQSP32’s internal supervisor tasks manage all background operations: input/output state handling, IoT connectivity, and system monitoring. On top of this, the user’s application logic processes sensor values and executes decisions to control loads and external devices according to the defined automation logic.
- Online Connectivity: The EQSP32 connects via Wi-Fi or Ethernet. Provisioning is managed through the EQConnect app, which also allows setting credentials, timezones, and MQTT configurations. Once connected, the controller communicates securely with the configured MQTT broker.
Role of the MQTT broker
The MQTT broker (local or cloud-hosted, e.g., Mosquitto or HiveMQ Cloud) acts as the bridge between EQSP32 and Node-RED:
- EQSP32 publishes sensor data and system information to state topics.
- Node-RED, acting as an MQTT client, subscribes to these topics to display data on dashboards.
- EQSP32 listens for control commands by subscribing on command topics.
- Node-RED publishes commands on the respective command topics to send any kind of control instructions to the EQSP32, like to control outputs.
Instead of the PLC sending data directly to Node-RED, it publishes messages to the broker, which then distributes them to all subscribed clients.
This approach makes the system scalable, since multiple dashboards, services, or applications can access the same data without modifying the EQSP32 code. The broker also ensures reliable delivery, retains the last known values, and handles secure connections, making communication both robust and future-proof.
Preparing Node-RED and dashboard
Node-RED setup options
As mentioned above, Node-RED is a flow-based programming tool for wiring together hardware devices, APIs, and online services. It can run on a variety of platforms. Here are the most common ways to install and use it:
Option 1: Node-RED on PC (Windows/Linux/Mac)
- Ideal for development and testing
- Lightweight and quick to set up
- Runs locally using your computer’s resources
Option 2: Node-RED in Docker
- Best for scalable or containerized deployments
- Runs consistently across devices and environments
- Easy to back up, update, or move
Option 3: Node-RED on Raspberry Pi
- Perfect for edge computing or local automation
- Runs well on Raspberry Pi 3 or later
- Can be integrated with GPIO and sensors
Option 4: Node-RED in the Cloud
- Services like IBM Cloud or FlowFuse offer hosted Node-RED
- Great for remote dashboards or multi-site monitoring
- Limited hardware integration unless tunneled
For this guide, we’ll focus on:
Option 1: Node-RED on PC — which is the easiest way for most users to test EQSP32 integration locally. As an MQTT broker we may use any solution, like Mosquitto, Hive, etc., running locally or remotely.
Follow the official Node-RED installation guide for your operating system. For Windows users, the step-by-step instructions are available here: https://nodered.org/docs/getting-started/windows
Start Node-RED
Once Node-RED is installed, you can start it from the command line by running: node-red.
When the service is running, open your web browser and navigate to: http://localhost:1880/
This will launch the Node-RED editor, where you can begin creating flows and connecting them with EQSP32.
Install MQTT nodes and dashboards
Node-RED supports MQTT out of the box, but if the MQTT nodes are not available in your installation, you can add them manually:
- Go to the top-right menu → Manage palette
- Click Install Tab
- Search for
node-red-node-mqtt - Click Install
To enable user interface elements such as switches, gauges, and charts, install the Node-RED Dashboard package:
- Go to the top-right menu → Manage palette
- Click Install Tab
- Search for
node-red-dashboard - Click Install
With MQTT support and dashboard nodes in place, you’ll be ready to design a user interface dashboard in Node-RED, set up an MQTT broker project (or cloud cluster), implement interfacing entities on the EQSP32 side, and finally connect everything together in a live demo.
Designing the Node-RED user interface dashboard
To display sensor values and interact with EQSP32, we’ll build a simple dashboard in Node-RED. Dashboards are organized into tabs and groups, where each group holds the UI widgets (text, gauges, charts, switches, etc.).
Create Dashboard Groups
- Open the Dashboard sidebar (right-hand side of the editor).
- Hover over the desired tab (e.g., Home) and click “+ group”.
- For this example, create two groups:
- Monitoring → for displaying sensor values (UpTime, Temperature, etc.)
- Controls → for controlling outputs (Relay switch, etc.)
- Hover over each group, click Edit, give it a descriptive name, then press Update.
Add UI Elements
- Browse through the node palette on the left and scroll down to dashboard nodes.
- Drag and drop the following elements into your flow:
- Text → to show current values.
- Gauge → to display UpTime and Temperature.
- Chart → to show historical temperature trends.
- Switch → to toggle the relay ON/OFF.
- Double-click each node and configure:
- Group → Monitoring or Controls.
- Label → e.g., “System UpTime”, “Temperature °C”, “Relay Control”.
- Range → e.g., UpTime (0–86400), Temperature (0–100 °C).
- Appearance → adjust icons or units for clarity.
Deploy and View the Dashboard
Once all elements are configured:
- Click Deploy to save and apply the flow.
- Open your browser at: http://localhost:1880/ui
You should now see your custom dashboard displaying both monitoring and control groups.
Preparing the MQTT broker
For this demo, we will use HiveMQ Cloud as the MQTT broker, but any MQTT broker (local or remote, such as Mosquitto or EMQX) will work. HiveMQ Cloud offers a free plan, which is sufficient for testing EQSP32 integration with Node-RED.
Create a HiveMQ cloud cluster
- Go to the HiveMQ Cloud Console: https://console.hivemq.cloud/
- Press the “+” symbol next to Clusters Overview or use one of the “Get Started” buttons.
- Select the Free Serverless Cluster plan and press Create Cluster.
- Wait until your cluster is provisioned and ready.
Add access credentials
Once we have our MQTT cluster created we need to add device/user access credentials from the Access Management tab. In our demo, we are going to create a single set of username and password and use it in both Node-RED and EQSP32 to access the cluster.
- In the HiveMQ console, open the Access Management tab.
- Create a new user by defining a username and password.
- Ensure that this account has both publish and subscribe permissions.
- This is required because EQSP32 publishes sensor data and listens for commands, while Node-RED also needs to do both.
Find cluster connection details
Return to the Cluster Overview page and copy the following details:
- Broker URL (for example: abcd12345.s1.eu.hivemq.cloud)
- Port (typically 8883 for secure TLS connections)
These parameters will be needed in the EQSP32 configuration code and in the Node-RED MQTT broker settings so both can securely connect to HiveMQ Cloud.
Developing the EQSP32 integration
Creating EQSP32 interfacing entities for interacting with Node-RED
Before we jump into the code, let’s clarify what we want to achieve. EQSP32’s library provides built-in functions to create interfacing entities that automatically create, publish, and subscribe to MQTT topics for each one. Each entity is exposed as either a sensor (publishing state only) or a control switch/value (bi-directional, allowing external commands).
In this example, we will configure EQSP32 to connect to an MQTT broker (HiveMQ Cloud, in our case) and handle three different entities that demonstrate both real-time monitoring and control, integrating our EQSP32 system with the Node-RED UI we have prepared.
Specifically, we will implement: a virtual up-time counter that publishes the controller’s running time in seconds periodically, a temperature sensor that measures and reports the value of an NTC thermistor in °C, and a virtual toggle switch for controlling a relay remotely from Node-RED.
The following sample sketch is developed with the help of EQ-AI code assistant. It configures the EQSP32 controller to act as an MQTT-enabled device, connected to HiveMQ Cloud. It demonstrates real-time monitoring and control of three entities:
- System UpTime (Virtual Sensor)
- Tracks how long the device has been running since power-up.
- Publishes the value every second to the MQTT broker as an entity named UpTime.
- Allows external dashboards (like Node-RED) to visualize runtime.
- Temperature Sensor (TIN on Pin 1)
- Configures Pin 1 as a TIN (Temperature Input) for an NTC thermistor.
- Uses Beta constant and reference resistance for conversion.
- Reads the sensor, converts the raw reading into °C, and publishes it over MQTT as the entity Temperature.
- Handles error states (open/short sensor) and reports 0 if invalid.
- Relay Control (Relay on Pin 16)
- Configures Pin 16 as a relay output with power derating enabled (40% holding current, 1500ms delay).
- Creates an MQTT control entity named Relay Control.
- Listens for incoming MQTT commands (cmd/<DeviceID>/Relay_Control) and drives the relay ON/OFF accordingly.
- Once the new command is read, it automatically reflects the switch state back to MQTT so we can also update the switch state from the EQSP32 and dashboards stay synchronized.
Click to reveal “EQSP32 code for MQTT”
#include <EQSP32.h>
EQSP32 eqsp32;
EQTimer updateTimer(1000);
// Entities
std::string uptimeEntity = "UpTime";
std::string relayEntity = "Relay Control";
std::string tempEntity = "Temperature"; // New temperature entity
// Pin assignments
#define RELAY_PIN 16 // ⚡ Relay-capable pin
#define TEMP_PIN 1 // 🌡️ Temperature input (TIN)
// Thermistor parameters (adjust if using different NTC)
#define NTC_BETA 3435 // Beta value
#define NTC_REF_RESISTANCE 10000 // Reference resistance in Ohms
void setup() {
Serial.begin(115200);
Serial.println("\n🚀 Starting EQSP32 UpTime + Relay Control + Temperature Demo...");
// MQTT Broker Settings
EQSP32Configs myConfigs;
myConfigs.mqttBrokerIp = "Your broker URL";
myConfigs.mqttBrokerPort = 8883; // HiveMQ Cloud default TLS port
myConfigs.mqttDiscovery = true; // Allow discovery
// Optional: HiveMQ Cloud CA certificate if required
// myConfigs.mqttBrokerCA = "-----BEGIN CERTIFICATE-----\n...paste HiveMQ Cloud CA cert...\n-----END CERTIFICATE-----\n";
// Start EQSP32
eqsp32.begin(myConfigs, true);
// Configure relay output
eqsp32.pinMode(RELAY_PIN, RELAY);
eqsp32.configRELAY(RELAY_PIN, 400, 1500);
eqsp32.pinValue(RELAY_PIN, 0); // Start OFF
// Configure temperature input
eqsp32.pinMode(TEMP_PIN, TIN);
eqsp32.configTIN(TEMP_PIN, NTC_BETA, NTC_REF_RESISTANCE);
// Create MQTT entities
createDisplay_Sensor(uptimeEntity); // UpTime
createControl_Switch(relayEntity); // Relay control
createDisplay_Sensor(tempEntity); // Temperature
updateTimer.start();
}
void loop() {
// --- UpTime publishing ---
if (updateTimer.isExpired()) {
updateTimer.reset();
unsigned long uptimeSeconds = millis() / 1000;
updateDisplay_Sensor(uptimeEntity, uptimeSeconds);
Serial.printf("⏱ Published UpTime: %lu seconds\n", uptimeSeconds);
// --- Temperature reading & publishing ---
int tempValue = eqsp32.readPin(TEMP_PIN);
if (IS_TIN_VALID(tempValue)) {
float tempC = tempValue / 10.0; // TIN values are °C * 10
updateDisplay_Sensor(tempEntity, tempC);
Serial.printf("🌡️ Published Temperature: %.1f °C\n", tempC);
} else {
Serial.println("⚠️ Temperature sensor error (open/short).");
updateDisplay_Sensor(tempEntity, 0); // Optionally publish 0 or leave unchanged
}
}
// --- Relay control from MQTT ---
bool relayState = readControl_Switch(relayEntity);
eqsp32.pinValue(RELAY_PIN, relayState ? 1000 : 0);
delay(10); // FreeRTOS-friendly main loop
}
Once the code has been uploaded to the EQSP32, we need to configure the MQTT credentials so the device can authenticate with the broker. This is done using the EQConnect mobile application.
A short walkthrough is available here:
After updating the MQTT username, password, and related settings in EQConnect, reset the EQSP32 so the changes take effect.
When the device reboots and successfully connects to the broker, it will print a list of system topics (supply voltage input & output and WiFi signal strength) and user-defined topics (e.g., UpTime, Temperature, Relay Control) to the Serial Monitor. These topics can then be used in Node-RED to build dashboards and automation flows.
For our demo, we will work with the following MQTT topics:
Monitoring Topics
- [System topic] state/EQSP32_22DD64/signalStrength
- [User topic] state/EQSP32_22DD64/Temperature
- [User topic] state/EQSP32_22DD64/UpTime
Control Topics
- [User topic] cmd/EQSP32_22DD64/Relay_Control
The topic generation follows a simple structure:
- Monitoring Topics → state/{device unique ID}/{sanitized_entity_name}
- Command Topics → cmd/{device unique ID}/{sanitized_entity_name}
The device unique ID is created automatically using the prefix EQSP32_ followed by the last three bytes of the device’s MAC address. In this example, the ID is EQSP32_22DD64.
In addition to user-defined entities, EQSP32 also generates three built-in system topics by default:
- Input voltage
- Output voltage
- WiFi signal strength
These system topics could provide valuable diagnostic information and can be used in Node-RED alongside user topics for monitoring.
Testing the MQTT connection on EQSP32 side
If the EQSP32 has successfully connected to the MQTT broker, it will print all system and user topics in the Serial Monitor. This confirms that the device has registered its entities and is ready to publish and subscribe.
To further verify the connection, open your HiveMQ Cloud cluster and navigate to the Web Client. Connect using either the access credentials you created or the auto-generated ones provided by HiveMQ. Once connected, subscribe to all messages to observe the data being published by EQSP32.
If there are no received messages, verify that URL, port and access credentials have been set correctly on the EQSP32 and that there is an active WiFi or Ethernet connection (device should be online to access the remote MQTT broker).
If no messages are received, double-check the following:
- The broker URL and port are correctly configured in the EQSP32 sketch.
- The MQTT username and password are correctly set using EQConnect.
- The MQTT access credentials have publish/subscribe permissions.
- The EQSP32 has an active WiFi or Ethernet connection, since the device must be online to reach the remote MQTT broker.
Integrating the generated topics in Node-RED
Now that EQSP32 is successfully connected to the MQTT broker, we can integrate the generated topics into Node-RED.
- In your Node-RED flow, open the node palette and locate the network nodes.
- Drag one mqtt in node for each monitoring topic, and one mqtt out node for the control topic.
Configure MQTT Connection
1. Double-click any MQTT node, find the Server property and press the plus symbol “Add new MQTT broker”.
2. In the Connection tab, enter your broker URL and port. For HiveMQ Cloud, use port 8883 and enable TLS option.
3. Go to the Security tab and insert the username and password you created in the HiveMQ console.
4. Press Update to save.
5. Assign topics to MQTT nodes.
Paste the generated topics into their respective MQTT nodes, making sure each one is linked to the newly configured server (e.g., “My Demo HiveMQ”):
- state/{deviceID}/signalStrength
- state/{deviceID}/Temperature
- state/{deviceID}/UpTime
- cmd/{deviceID}/Relay_Control
6. Next, connect these MQTT nodes to the corresponding UI dashboard elements (Text, Gauges, Chart, and Switch).
Deploy and verify real-time operation of final UI
- Press Deploy in Node-RED to apply the configuration.
- Open your UI at http://localhost:1880/ui and confirm that values update in real time.
- Toggle the Relay Control switch in the dashboard. You should see a “Command Received” message from the EQSP32 MQTT handler task in the Serial Monitor.
If you do not see EQSP32 system messages in Serial Monitor, make sure that verbose logging is enabled in the EQSP32 configuration.
Related products
EQSP32CE – Industrial IoT ESP32 PLC With Ethernet
EQSP32C – Industrial IoT ESP32 PLC
EQSP32C-X – Industrial IoT ESP32 PLC With External Antenna
Take a look at our product catalog of EQSP32 controller versions and our range of expansion modules — we’re always happy to assist you with your selection and integration process.
Have questions? Feel free to reach out to us at info@erqos.com.