+8618758069661 [email protected]
Product Search Guide: space = AND, | = OR, ! = NOT

Modbus RTU, Modbus TCP, MQTT and JSON for Cloud Telemetry

Got any Questions? Call us Today!

+8618758069661

Or leave us a message

Online Message

Modbus RTU, Modbus TCP, MQTT and JSON for Cloud Telemetry

Views: 24 +24Original by FCTELEAuthor: FCTELE Technical Team

Industrial telemetry

What happens between the meter and the database?

Modbus reads the register. The gateway applies the instrument’s scale to produce 23.5 °C and records it as a JSON number with its unit and sample time. MQTT carries that payload under a topic. A matching subscriber can receive the message, then validate the fields and decide whether to store it.

01

Collect a register

The RTU meter responds with the register value 235. GatewayMeter Read requestRegister 235

The RTU meter responds with the register value 235.

02

Assign a value and a type

Scaling produces a JSON number, which the platform checks against its field definition. 235 × 0.1 = 23.5 °C "temperature": 23.5

Scaling produces a JSON number, which the platform checks against its field definition.

03

Distribute by topic

The broker sends matching messages to each subscriber. Each subscriber handles the payload independently. GatewayBroker ViewStore

The broker sends matching messages to each subscriber. Each subscriber handles the payload independently.

Read the register

Compare raw 235 with the point map and display.

Capture the payload

Check that temperature is a number and the agreed unit is present.

Check application receipt

Trace sample 42 in the subscriber logs and database.

Selection and verification checklist Expand
Check Confirm How
Acquisition Serial RTU or Ethernet Modbus TCP Read a known register and compare the response with the meter map.
Payload Field type, unit and time Match the raw JSON to the platform’s field definitions.
Delivery Topic and storage Compare the actual topic with the subscription and find the event in storage logs.

A temperature meter reads 23.5 °C. How does the same number reach a cloud application? A gateway reads a register over Modbus RTU or Modbus TCP, converts the raw value using the meter's register map, and puts the result in JSON. It then publishes the message over MQTT so subscribed applications can receive it. Following one reading through that path explains what each technology does and why a successful publish can still leave a dashboard blank.

Temperature meter and cutaway gateway showing the Modbus RTU reading, point mapping, JSON and MQTT.
Figure 1. Arrows follow the reading from the meter response through point mapping and JSON formatting to MQTT delivery. An Ethernet meter can instead use Modbus TCP for acquisition. Original FCTELE illustration, AI-assisted. Generic engineering example.

What each technology does

Imagine a temperature meter wired to a gateway over RS-485. At regular intervals the gateway sends a request, and the meter responds. This exchange uses Modbus RTU. An RTU message contains a device address, a function code, data and a cyclic redundancy check (CRC). The address identifies the device on the bus, the function code says what to do, and the CRC helps detect transmission errors. The two devices also need matching serial settings and a shared understanding of how the meter manual numbers addresses.

With an Ethernet meter that supports Modbus TCP, the gateway can make the same kind of read request over a TCP connection. The function codes and meaning of the data stay the same, while an MBAP header supplies network framing information. Its transaction identifier helps the client match a reply to a request. A standard Modbus TCP message omits the trailing CRC used in RTU. RTU and TCP are two choices at the acquisition stage. A gateway can collect directly from an RTU meter and publish over MQTT without an intermediate Modbus TCP hop.

Four technologies in one reporting path
Technology Role in this example What you can inspect
Modbus RTU Read the meter's register over a serial link. Device address, function code, data and CRC.
Modbus TCP Read a compatible meter or gateway over a TCP connection. MBAP header, function code and data.
JSON Represent temperature, unit and sample time as named fields. A text object with values and types.
MQTT Publish a message to a topic for the broker to distribute. Topic, payload and delivery status.
An example test screen shows the register value 235, scale factor 0.1 and temperature 23.5 degrees Celsius.
Figure 2. The gateway uses the point map to convert 235 to 23.5 °C before putting the result in JSON. The screen is an example diagnostic view. Original FCTELE illustration, AI-assisted. Generic engineering example.

How JSON gives the value 235 a meaning

Suppose the meter manual defines one holding register as a signed integer in steps of 0.1 °C. The gateway uses function code 03 to read it and gets a raw value of 235. Its point map identifies the register as a temperature measurement and tells the gateway to multiply it by 0.1. The result is 23.5 °C. The scale comes from this example's register map. Another meter could return 235 with a different data type, unit or meaning. If the display changes from 23.5 to 24.0 °C, check that the raw value moved from 235 to 240 before investigating the outgoing message.

The gateway can represent the result as the JSON object below. Braces enclose the object. Double quotes mark field names and strings, while the number 23.5 appears without quotes. Here, sampled_at gives the agreed sample time and seq is the sample number from the example device. The fields and timestamp are illustrative.

{
  "device_id": "meter-01",
  "temperature": 23.5,
  "unit": "Cel",
  "sampled_at": "2026-12-02T09:00:00+08:00",
  "seq": 42,
  "quality": "good"
}

JSON allows temperature to be the number 23.5 or the string "23.5". A JSON parser can read both, but a platform that expects a number can reject the string. Calling the field temp or sending a different unit value can also break the binding to a measurement. Agree on field names, types, units, missing values, sample time and version before connecting the system. This is how a syntactically valid object becomes a reading that the dashboard and database can use.

Three small edits help show where checks happen. Drop the double quotes around a field name and the parser rejects the syntax. Add double quotes around 23.5 and parsing succeeds, but the value becomes a string. Leave the value numeric and associate it with the wrong meter, and both syntax and type checks can pass. You then need to inspect point mapping, device identity and topic assignment. Keep the raw subscriber payload when troubleshooting because a display tool may render a numeric string just like a number.

If a meter read times out, an agreed payload could report quality as timeout and set the value to null. A dashboard can still show the last valid reading, marked stale and accompanied by its sample time. This leaves zero available for a genuine zero measurement and gives an unsuccessful read its own representation. Distinguish the meter's sample time, the gateway's acquisition time and the server's receipt time. If a meter supplies no timestamp, define the field as the time the gateway acquired the value.

A gateway publishes to an MQTT broker, which distributes the message to a dashboard and database service.
Figure 3. Blue lines show logical MQTT links. The publisher sends the reading to the broker, which sends it to matching subscribers. Each application interprets its own payload and records its processing result. Original FCTELE illustration, AI-assisted. Generic engineering example.

How MQTT delivers the JSON to subscribers

The three roles are publisher, subscriber and broker. The gateway connects to the broker and sends a PUBLISH message on a topic such as factory/line1/meter-01/telemetry. The topic has its own field in the MQTT packet. The encoded JSON bytes go into the payload. Publishers and subscribers can agree to use JSON, another text format or a binary format.

The dashboard and database service make their own connections and subscriptions. A dashboard might subscribe only to the meter's full topic. The database service can subscribe to factory/line1/+/telemetry to collect readings from all meters on the line. In a subscription filter, the plus sign matches one topic level. Publishers send to a concrete topic name. The broker distributes matching messages, and each application interprets the payload. Both applications can receive the same message and reach different processing outcomes.

Publish the same JSON to factory/line2/meter-01/telemetry for a simple comparison. The line 1 filter misses it even when the device ID and temperature are identical. Now send to the line 1 topic again and change temperature to a string. A subscriber tool can show the message while the storage application rejects the type. Each test changes one condition, letting you tell topic matching and payload validation apart.

What acknowledgments, offline sessions and retained messages tell you

Quality of Service (QoS) specifies the MQTT delivery behavior. QoS 0 has no per-message acknowledgment at the MQTT layer. It can suit regularly refreshed readings when occasional gaps are acceptable. QoS 1 uses an acknowledgment and provides at-least-once delivery, so retries can produce duplicates. QoS 2 adds protocol exchanges for exactly-once delivery at that MQTT hop. The gateway-to-broker and broker-to-subscriber hops are separate, and the outgoing hop can use a different QoS based on the subscription. A successful PUBACK tells the gateway that its QoS 1 exchange was acknowledged. Check the subscriber's application records to see whether the reading was stored.

Take sample 42. The broker can receive it and the database service can get the payload, yet a string temperature can still fail a type check. After correcting the field, a later retry may deliver that event again. The storage application can deduplicate using a stable event identifier. An identifier built from device ID and sequence number needs a guarantee that the sequence is unique within a device run and a way to distinguish runs after restarts. MQTT packet identifiers apply within their respective protocol exchanges and can be reused.

A retained message gives a new matching subscriber the latest publication retained for a topic. If a dashboard opens and immediately displays 23.5 °C, check the sample time to see how recent the reading is. Queuing while a subscriber is offline depends on session settings, QoS, broker limits and expiration rules. If the gateway must resend historical readings after its own connection returns, check what the gateway buffers, how long it preserves data and how it resumes.

Record the acquisition and publication intervals separately. Suppose a gateway polls the meter once per second and sends the most recent valid sample once every ten seconds. The dashboard refreshes with the publication schedule. Whether the other samples are saved depends on the gateway and application settings. If the meter connection fails while MQTT stays connected, the gateway may still report the previous value or a data-quality status according to its configuration. Use the sample time, receipt time and quality field together to identify a fresh reading.

Trace one known reading from the meter to storage

First, confirm that the meter or gateway log shows 235 and that the point map yields 23.5 °C. Use an authorized test subscriber to compare the actual topic and raw payload with the expected fields, types and timestamp. Then look up that event in the platform's receipt, processing and database records. If a subscription sees nothing, check the topic, subscription result and permissions. If messages arrive but the display stays empty, check field validation and measurement binding. If the display shows only an old value, compare the sample time and acquisition status and check whether the received message was flagged as retained. Agree on encryption, device identity and topic permissions so the test reflects the production setup.

The published specifications for the FCTELE FCT-6300-F2B1 and FCT-6300-F5 list Modbus RTU-to-TCP conversion, multi-topic MQTT publishing and subscribing, and Modbus-to-JSON conversion. Confirm the mode using the actual meter interface, gateway firmware and platform format. The topic and fields in this article are examples. Use the instrument map, interface agreement and options of the delivered gateway when setting up a real installation.

Sources and scope

Modbus Organization specifications and implementation guides · IETF RFC 8259 on JSON · OASIS MQTT Version 5.0

FCT-6300-F2B1 industrial cellular gateway · FCT-6300-F5 industrial cellular gateway

Common practical questions

Must an RTU meter go through Modbus TCP to reach the cloud?

A gateway with active polling and MQTT publishing can read the RTU meter directly and publish the result. Modbus TCP conversion is useful when another device needs to read over Modbus TCP.

Does every MQTT message use JSON?

MQTT delivers payloads by topic. The publisher and subscriber agree on the payload format, which may be JSON, another text format or binary.

Why can the platform still show no new reading after PUBACK?

A successful PUBACK acknowledges the current QoS 1 hop. Check that the platform received a matching publication, validated the payload fields and completed its own processing.

Further reading

Modbus registers and word order · 4G and 5G RedCap router applications

English translation of the original FCTELE technical article. Read the original in Chinese.

Share this article