Troubleshooting
Fix MQTT sensor data missing in Node-RED
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
- Why doesn't the http in node show MQTT messages?
- What does the broker connected status actually prove?
- How do you check the sensor value over RS-485 first?
- How do you confirm the GSM module is actually publishing?
- Do the topic strings match on both sides?
- How do you verify the whole path stage by stage?
- 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.
- Poll the sensor in the GSM module's software and confirm a fresh value.
- Confirm the module reports a publish for that poll and write down its exact topic string.
- Confirm the module's broker address matches the broker in Node-RED's MQTT configuration.
- Replace the
http indiagnostic with anmqtt innode subscribed to that exact topic. - Wire the
mqtt inoutput to a debug node, deploy, poll again, and watch the debug sidebar. - 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.