GreatLight CNC Machining Factory logo
CNC Machining
Rapid Prototyping
Materials
Industries
News
About GL

Get Instant Quote

Protocol Explainer

MQTT Data Acquisition Gateway: How It Moves Field Data

An MQTT data acquisition gateway sits between sensors and your server, translating Modbus or analog signals into MQTT topics. This page explains the message flow, timing limits, and where the box belongs in a real cabinet.

Modbus to MQTTEdge bufferingDIN-rail mounting24 VDC supply
Enclosure parts for an mqtt data acquisition gateway built by CNC machining
Fundamentals

What an MQTT data acquisition gateway actually does

An MQTT data acquisition gateway converts a physical signal into a publishable message. On one side it speaks to hardware: RS-485 carrying Modbus RTU, CAN bus, 4–20 mA current loops, 0–10 V analog, or a dry contact. On the other side it speaks TCP to a broker and posts payloads to named topics. The gateway is the translator, not the database.

The distinction matters when you scope a project. A gateway does not store a year of trend data and it does not run your alarm logic on the server. It samples, formats, and pushes. If you need retention or cross-device rules, those live in the broker or a time-series database behind it.

Most units on the market follow the same internal order: read the register map, scale the raw value, stamp it with a timestamp, serialize it, then publish. Each of those steps can fail on its own, which is why the fault behaviour of a gateway matters more than its feature list.

Keep the box close to the signal source. A gateway mounted 200 mm from the sensor costs less in cable and picks up less noise than one mounted in a control room 30 m away.

Message flow

Poll, buffer, publish: the three clocks inside the box

Every gateway runs three timing loops that do not share a clock. The acquisition loop reads the field device, the buffer loop decides what to keep when the link drops, and the publish loop talks to the broker. When these three drift apart, you get duplicate tags, missing samples, or timestamps that no longer line up with the process.

A common setup reads Modbus at 100 ms and publishes at 1 s. That means ten register reads are compressed into one payload. If the register changes twice inside that second, you lose the intermediate value unless the gateway is configured to publish on change rather than on a fixed interval.

Buffer depth is the number that gets ignored in the datasheet. Ask how many samples survive a 10-minute network outage. A gateway with a 500-sample ring buffer at a 1 s publish rate holds about eight minutes. Beyond that, data drops and nobody notices until the trend chart has a hole in it.

Publish on change sounds efficient until you hit a noisy analog input. A 4–20 mA loop with 2 mV of ripple can trigger hundreds of messages per minute. Set a deadband, usually 0.5–1% of span, before you enable that mode.

Timing and load

Latency, jitter, and what the network adds

Local acquisition latency on a gateway is typically single-digit milliseconds. The number your control room sees is larger because it includes broker hop, WAN transit, and any TLS handshake on top. On a cellular link, budget 80–300 ms round trip. That is fine for monitoring and wrong for closed-loop control.

Jitter matters more than average latency. A gateway that publishes every 1.00 s ± 5 ms gives you clean data. One that publishes every 1.00 s ± 400 ms makes derivative calculations useless. If your application needs to compute rate of change, log the gateway timestamp, not the server receive time.

QoS level changes the picture again. QoS 0 gives you one attempt and no acknowledgement. QoS 1 guarantees at-least-once delivery, which means duplicates under retry. QoS 2 adds a four-part handshake and roughly doubles the round trips per message. For most sensor telemetry, QoS 1 with a deduplication key on the server is enough.

Subscribing back to the gateway is a separate load. If the server pushes new setpoints or configuration down the same link, the gateway now has to interleave inbound and outbound traffic. Check whether the firmware handles that without starving the acquisition loop.

Wiring and environment

Where the gateway sits in the cabinet

Power the gateway from the same 24 VDC rail as the sensors where possible. A separate supply introduces a ground offset that shows up as noise on analog channels. Keep the RS-485 shield grounded at one end only, normally the gateway end, and keep the stub length under 100 mm.

DIN-rail mounting is the default for a reason, but thermal design is often overlooked. A sealed IP67 enclosure with no airflow will run 15–20 °C above ambient. If the datasheet rates the unit to 70 °C, that rating assumes free air. In a closed box, derate it.

Cable routing decides more outcomes than the gateway model does. Run signal pairs away from VFD output cables by at least 200 mm, cross at 90°, and never share a cable tray without a grounded divider. Most intermittent gateway faults we see trace back to routing, not firmware.

If the gateway must live on a moving axis, strain-relieve the cable at both ends and specify a flex-rated jacket. Fixed-installation cable fails in weeks on a moving gantry.

Edge vs cloud

How much processing belongs at the edge

Every value you publish costs bandwidth, storage, and someone's attention. Filtering at the gateway reduces all three. Deadband on analog channels, change-of-state on discrete tags, and aggregation of high-rate counters into per-minute totals are the three filters that pay back fastest.

Aggregation needs care. If you publish only a 1-minute average, you cannot recover a 3-second spike later. Publish the average plus min and max for the interval. That is three values instead of sixty, and the spike is still visible.

Some gateways allow a small script or rule engine. Use it for local decisions that must survive a network outage: close a valve, raise a discrete alarm, latch a fault. Do not use it as a general application runtime. Memory and CPU on a gateway are sized for protocol work, not for business logic.

The split we recommend: convert and filter at the gateway, store and correlate in the cloud. Anything that must act within a second stays local.

Selection

Specification numbers worth checking before you buy

Start with channel count and isolation. A gateway with eight isolated analog inputs is a different product from one with eight channels sharing a common ground. Isolation per channel costs more and saves you when a sensor shorts to a 24 V rail.

Then check protocol coverage against your actual device list. Modbus RTU is nearly universal. Modbus TCP, CANopen, and vendor-specific serial protocols are not. Ask for the register map support list, not just the protocol name.

Security features belong on the checklist too. TLS 1.2 or higher, per-device certificates, and the ability to disable the web interface are baseline for anything reachable from outside the plant network. A gateway that only offers a fixed password should not face the internet.

Finally, confirm the firmware update path. A unit that can only be updated by physical USB means every security patch requires a site visit. Over-the-air update with signed images is worth paying for.

Decision table

When a gateway is the right box, and when it is not

Match the architecture to the data rate and the required response time.

ScenarioGateway fitsBetter option
10–50 Modbus sensors, 1 s updatesYes, single unit covers it—
Sub-10 ms control loopNo, network adds jitterLocal PLC or drive
Cellular backhaul, intermittent linkYes, with deep buffer—
Video or waveform streamingNo, payload too largeEdge computer
Legacy RS-232 machine, cloud dashboardYes, protocol conversion—
On-device alarm and interlock logicLimited, basic rules onlyEdge controller
Mixed Modbus and CAN on one siteYes, if dual-port modelTwo gateways
Regulatory data retention over yearsNo, buffer is shortTime-series database

Pick the box that matches the loop

If the data feeds dashboards and slow trending, an MQTT data acquisition gateway is the correct and cheapest answer. If anything must react in under a second, keep that logic in a local controller and let the gateway report on it.

FAQs

Common questions

How many sensors can one gateway handle?

It depends on the poll budget, not the channel count. A unit polling 50 Modbus registers at 100 ms is already busy. Add analog channels and protocol conversion and the practical ceiling drops.

Count total transactions per second across all ports, then compare with the published figure. Leave 30–40% headroom for retries and firmware overhead.

Does the gateway keep data when the network drops?

Only up to its buffer size. Ask for the buffer depth in samples and the behaviour when it fills: oldest dropped, newest dropped, or sampling paused.

For a link that fails for hours, add local logging on removable storage or accept the gap in the trend.

Is MQTT secure enough for a plant network?

Yes, with TLS and per-device certificates. Plain MQTT on port 1883 sends payloads in clear text and should stay inside an isolated segment.

Use port 8883 with TLS 1.2 or higher, disable anonymous access on the broker, and give each gateway its own credential.

Can the gateway replace a PLC?

No. Gateways lack the deterministic scan cycle, the certified safety functions, and usually the I/O density. They report on the process; they do not run it.

Where a machine already has a PLC, the gateway reads from it over Modbus TCP or OPC UA and forwards upward.

What causes duplicate readings in the dashboard?

QoS 1 retries after an unacknowledged publish produce duplicates. The broker delivers the message again because it never saw the acknowledgement.

Add a unique message ID and a timestamp to each payload, then deduplicate on the server by that key.

How do I size the power supply for a gateway plus sensors?

Add the gateway draw, the sensor draw, and the inrush of any relay or valve on the same rail. Then check the supply against the worst-case ambient temperature.

A 24 VDC supply rated 2 A at 25 °C may only deliver 1.4 A at 60 °C inside a sealed cabinet.

Send us the enclosure or the bracket

We machine gateway housings, DIN-rail clips, and mounting plates to your drawing, with a quotation and free DFM analysis within 12 hours.

12-hour quote100% inspectionNo minimum order quantity

Follow

More from the shop floor

We publish setup notes, tooling trials and inspection data from the factory floor.

FacebookTikTokYouTubeLinkedInInstagramThreadsPinterest

Trusted by engineers and manufacturers worldwide

Tesla Ford Motor Company BYD Auto Denso Magna International Boeing Airbus Medtronic KUKA FANUC