IMD SolutionComputing LibraryShop main store

Troubleshooting

Fix MQTT sensor data missing in Node-RED

Edge computing and IIoT Published 6 min read

Short answer

A green MQTT connection in Node-RED proves only a broker session, not that the GSM module published a value or that the flow subscribes to its topic. An http in node cannot receive MQTT publications at all: use an mqtt in node. Trace RS-485 acquisition, publish result, broker identity and topic match in order, and fix the first stage with no positive result.

On this page
  1. Why doesn't the http in node show MQTT messages?
  2. What does the broker connected status actually prove?
  3. How do you check the sensor value over RS-485 first?
  4. How do you confirm the GSM module is actually publishing?
  5. Do the topic strings match on both sides?
  6. How do you verify the whole path stage by stage?
  7. Questions asked

The reading is missing because an MQTT broker connection proves only a session, and an http in node cannot receive MQTT publications at all. Replace the HTTP diagnostic with an mqtt in node subscribed to the exact topic the GSM module publishes, then trace the four stages — RS-485 acquisition, publish result, broker identity, topic match — and fix the first one that shows no positive result.

Why doesn't the http in node show MQTT messages? #

Because the http in node receives HTTP requests made to the endpoint it defines, and a GSM module publishing over MQTT never makes one: broker publications reach Node-RED only through an mqtt in node attached to that same broker.

An HTTP endpoint is a request/response conversation — something has to issue a GET or POST to it. MQTT is publish/subscribe over a broker session. Unless a separate component converts MQTT to HTTP, the two never meet, so the http in node stays silent no matter how healthy the broker path is.

Node What it receives Use it when
http in An HTTP request sent to its configured endpoint The sender actually makes HTTP requests
mqtt in Every publication the broker delivers on a matching topic The GSM module publishes MQTT — your case

The MQTT nodes are part of the core palette you get when you install Node-RED natively on a Linux edge computer, so this diagnostic needs no extra installation on the edge box.

What does the broker connected status actually prove? #

Only that Node-RED completed a session with the broker — nothing about the sensor being read, the module publishing, or the subscription matching, so treat it as one green light among four, not a health check.

MQTT is broker-mediated: the publisher and the subscriber never contact each other, and the broker delivers a publication only to clients whose subscription matches its topic — that is how MQTT clients publish and subscribe through the broker. Three separate facts must all hold at once for your reading to appear: the module published, both sides use the same broker instance, and the Node-RED subscription matches the published topic. The connected indicator covers none of the three.

Decision: never close an MQTT data ticket on a connected indicator alone. Demand a message observed at a subscription.

How do you check the sensor value over RS-485 first? #

Read the sensor in the GSM module's own configuration or polling software before touching MQTT: if the value is absent or stale there, the fault is upstream of the broker and no Node-RED change will fix it.

The lag you see in the configuration software after polling is a serial-side clue. The USB cable to the IPC carries the software session while MQTT travels the LAN, so a slow or stalled software exchange points at the RS-485 link, not the broker. Compare the module's serial settings against the sensor documentation — wiring, baud rate, parity, device address and register — and read the module's own poll result.

What the module software shows Verdict Next check
A fresh value after every poll Acquisition works Move on to the publish check
A stale or absent value Fault is upstream of MQTT Wiring, baud, parity, device address, register
Software stalls during or after a poll The serial exchange is not completing Resolve the read before testing the broker path

A value that is never acquired can never be published as a current reading; no broker or Node-RED setting changes that.

How do you confirm the GSM module is actually publishing? #

Look for a publish result — a counter, log line or transmit statistic that increments each poll cycle — because the module's own broker indicator reports a session, and a session can exist with zero messages sent.

The module offers two different signals and only the second is evidence of data. Check its MQTT diagnostics for a reported publication carrying the poll's value, and record the exact topic string it names. If nothing is reported, inspect the module's publish configuration: whether publication is enabled and what triggers it.

If a publish is reported but Node-RED still sees nothing, confirm the module's broker address is the same broker instance that Node-RED's MQTT configuration points at — the same address, not two brokers with similar names on one plant network.

Do the topic strings match on both sides? #

Match them character for character, because MQTT routes strictly by topic: one wrong character, a different case, or one extra level and the subscription never receives the publication even though both sides stay connected.

A worked example of the most common miss:

Published by the module:   plant/line2/temp
Subscribed in Node-RED:    plant/line2/temperature

Both strings are three levels deep and agree on the first 12 characters (plant/line2/), but the publication's last level is temp, 4 characters, while the subscription expects temperature, 11 characters. They diverge at character 13, so the broker matches nothing — with both clients connected the whole time. Topics are also case-sensitive: Plant/line2/temp is a third, different topic.

To discover what is really being published, subscribe plant/line2/# for one test — # matches all remaining levels and must come last — and read the debug output; plant/+/temp works too, since + matches exactly one level. Or connect a desktop inspection client such as MQTT Explorer to the broker: it lists every topic the broker currently holds, which settles the publisher and the topic string in one look. Then set the subscription to the exact 16-character string plant/line2/temp and deploy.

How do you verify the whole path stage by stage? #

Run the six checks below in order and stop at the first one without a positive result — that stage is the fault; fix it and re-run from the top before moving on.

  1. Poll the sensor in the GSM module's software and confirm a fresh value.
  2. Confirm the module reports a publish for that poll and write down its exact topic string.
  3. Confirm the module's broker address matches the broker in Node-RED's MQTT configuration.
  4. Replace the http in diagnostic with an mqtt in node subscribed to that exact topic.
  5. Wire the mqtt in output to a debug node, deploy, poll again, and watch the debug sidebar.
  6. If the message appears, the transport is proven; any remaining gap is downstream flow logic.

If the message arrives at the debug node but the dashboard stays empty, the fault is now in your flow: a payload that is a JSON string nobody parses, or a function node expecting a number and receiving text. If nothing arrives even on a # subscription, the publication is not reaching that broker, and you return to step 2. Once the payload lands, moving it onward follows the same broker-and-topic discipline as bridging OPC UA PLC data to MQTT with an edge PC. One hardening rule as data starts to flow: require credentials on the broker connection so the sensor path is not an open port on the plant network.

Questions asked

Can one mqtt in node subscribe to more than one topic?

Yes. The node's subscription field accepts an array of strings as well as a single topic, so you can enter something like ["plant/line2/temp", "plant/line3/temp"] and receive both, with wildcards allowed inside each entry. Every entry is matched independently against the publications the broker delivers.

Why does MQTT Explorer show the sensor topic while Node-RED receives nothing?

That combination proves the broker holds the publication, so the fault is isolated to the Node-RED side: either its broker configuration points at a different broker address, or the mqtt in subscription string does not match the topic MQTT Explorer displays. Copy the topic from MQTT Explorer into the subscription, character for character, and deploy.

Why would data flow for a while and then stop until a restart?

A reported failure mode in the MQTT.js client library leaves a client showing connected while its publications silently stop after a reconnect. If the module's publish counter freezes after a network event, restart its MQTT service or force it to re-establish the session, and if the link drops regularly, plan a watchdog or scheduled reconnect.

Can the subscription be changed at runtime without redeploying?

Not with the core mqtt in node: its subscription is set in the node's configuration and applied at deploy time, so changing topics means editing the node and pressing deploy. Dynamic subscription, changing topics from message content, needs contributed nodes from the palette rather than the built-in MQTT nodes.

Does polling the sensor automatically publish the reading?

Not automatically. Polling the sensor and publishing the result are separate operations in a gateway: check which trigger the module is configured for — publish on every poll, on a fixed interval, or on change. If it publishes only on change and the sensor sits steady, the broker stays silent while acquisition looks perfectly healthy in the module software.

Keep reading

  • Explainer

    MQTT to Kafka edge data pipeline without losing messages

    Keep MQTT on the sensor side of the plant, put the Kafka-class durable log on the site or cloud side of the uplink, and give the boundary one disk-backed store-and-forward buffer sized to the longest outage you will ride through. At 500 messages per second and an 8-hour outage, that queue holds 14.4 million messages and about 9.6 GB — set the ceiling above it and alarm on overflow.

    Edge computing and IIoT

  • How-to

    Run Python and Node-RED beside PLC code on an edge PC

    Keep the IEC 61131-3 program in the controller runtime and run Python and Node-RED as separate Docker containers on the same edge PC. Exchange data over one MQTT interface with a fixed publish period, and declare data stale after three missed periods. One container per workload, and nothing from Python or Node-RED inside the control project.

    Edge computing and IIoT

  • How-to

    Bridging OPC UA PLC data to MQTT with an edge PC

    Keep the OPC UA server on the PLC side and give MQTT publishing its own role on a separate edge PC that acts as the OPC UA client and MQTT publisher. Commission the two links independently — first a verified tag read, then a verified subscriber message — and only then widen the tag set.

    Edge computing and IIoT

Fix npm E502 when installing Node-RED nodes behind a proxy