Get started: Modbus TCP
This tutorial reads live values from a Modbus TCP device — a PLC, an energy meter, an inverter, or a gateway — and shows them on a card. You'll create a shared Modbus connection, a Modbus TCP data source with two named points, a card that shows one of them, and a tap action that writes a new value back to the device.
Modbus has no messages or topics. The app asks the device for its register values on a timer (this is called polling). Each point you add gets a name, and every read gives you one value with a field per point, for example {"temperature": 21.5, "setpoint": 22}.
Before you begin
You need one data section on the home screen. If you already completed Get started: HTTP GET, reuse that section; otherwise create one (Add data section manually on the empty home screen, or from the menu).
You also need:
- A Modbus TCP device or gateway on your network, and its IP address. The standard port is
502. - Its register list from the device manual: which table each value is in, its address, and its data type.
- Its Unit ID. Most devices answer on
1. Behind a Modbus TCP gateway (for example to RS-485 devices), the Unit ID is the address of the device behind the gateway.
No device at hand? A Modbus TCP simulator on your computer works too. Run it on the same Wi-Fi network as your iPhone or iPad, allow its port in the computer's firewall, and use the computer's IP address as the host. Some computers need admin rights for port 502, so simulators often listen on another port, such as 5020.
The first time the app connects to a device on your local network, iOS asks whether Routix Dash may do that. Allow it. See Settings and safety.
This tutorial uses the two example registers below. Replace them with the ones from your device manual.
| Point | Table | Address | Data type | What it is |
|---|---|---|---|---|
temperature |
Holding register | 0 |
Float32 (2 registers) | A reading |
setpoint |
Holding register | 10 |
UInt16 | A value you can change |
1. Create a Modbus connection
Open the menu (top-right) → Modbus connections → Add Modbus connection.
On the New Modbus connection screen:
- Keep connected — on (default)
- Name —
My PLC - Host — the device's IP address, for example
192.168.1.50 - Port —
502(or your simulator's port) - Unit ID —
1
Leave the Advanced settings at their defaults for now: Timeout (ms) 2000 (200–60000; connecting waits at least 3 seconds), Word order ABCD, Address base 0-based (protocol), and Min gap between requests (ms) 0 (up to 5000). You might change Word order or Address base later if values look wrong — see Troubleshooting.
Tap Test in the top-right (next to the save tick). The app connects with your current settings and reads holding register 0. You don't need to save first.
- Holding register 0 = … — the link works.
- Device answered with exception …: the link works — also fine. The device answered; it just has no readable register 0 on that unit.
- No answer in … ms (check host, port and unit ID) — the device did not reply. See Troubleshooting.
Tap the save tick in the top-right.
See Data sources (incoming) — shared connections.
2. Add a Modbus TCP data source
Open the menu → Data sources → Add data source, or start from Add card → Data source → Add data source.
On the "New data source" screen:
- Set Name to
PLC values. - Set Data source type to Modbus TCP.
- Set Modbus connection to
My PLC. - Leave Unit ID at Connection default.
- Tap Points → Add point, and fill in the first point:
- Name —
temperature - Table — Holding register
- Address —
0 - Data type — Float32
- Name —
- Add a second point: Name
setpoint, Table Holding register, Address10, Data type UInt16.
A point name uses letters, digits, and _, and does not start with a digit. It becomes the field name in value, so transformers read it as value.temperature.
Leave Word order at Connection default. If the manual says a register holds tenths (235 means 23.5), set Scale to 0.1. Offset is added after the scale.
Tap Read now. The app reads the points once and shows each value with its raw registers. Check that the numbers look right before you go on. A huge or tiny number such as 3.4e+38 or 1.2e-41 usually means the word order is wrong — see Troubleshooting.
Leave Trigger at Auto (periodic) and Poll interval (ms) at 1000. The next read starts after the previous one ends, so a slow device never gets a pile of requests.
Tap the save tick in the top-right.
3. Show it in a card
On an empty section, tap Add card manually or Ask AI assistant to add card. Or turn on Edit layout, tap Add at the top, then Add card. In the library, pick Design your own card.
- Data source —
PLC values(already selected if you came from step 2)
Set PLC values as the card root data source. Add a Label — it inherits that source.
The Label now shows the whole value, for example {"temperature":21.5,"setpoint":22}. To show just the temperature:
- Select the Label.
- Under Data transformers pipe, tap Add... → Simple expression.
- Enter
value?.temperature.
Set Touches on the Label to Capture so the tap action in the next step runs when you tap that Label.
Tap the save tick in the top-right. The Label shows 21.5 and updates every second.
Want the setpoint too? Add a second Label with value?.setpoint, or try a Dial gauge for the temperature.
Details about each read — the device address, the Unit ID used, the number of requests, and how long the read took — are available in transformers as ctx.transport. See Expressions.
4. Write a value on tap
On the home screen, turn on Edit layout, tap the card, then tap its menu button and choose Edit.
Select the Label, then open Events → On tap and tap Add... → under Data actions, choose Modbus send.
Set:
- Modbus connection —
My PLC - Points — add one point: Name
setpoint, Table Holding register, Address10, Data type UInt16 - Value —
25
Save the card. Back on the home screen, tap the Label. The app writes 25 to holding register 10. Writes don't return anything to the tap; the new setpoint shows up with the next read.
What Value can be:
- A number,
true/false, or plain text — written to the single point (plain text for a String point). The action must then have exactly one point. - A JSON object — each key that matches a point name is written to that point, for example
{"setpoint": 25}. Other keys are ignored. If no key matches, the write fails. To write some points only, send just those keys. - Empty — the current value of the tap run is written, with the same rules.
Value can include {{ value?.field }} or {{ env.my_key }} — the value is filled in when you tap.
Decimals are rounded for whole-number types (2.6 writes 3), and true writes 1 to a register. A value out of range for the data type, or text longer than the point's registers, is refused before anything is sent. A failed send stops the rest of the tap, so a Toggle skips Apply value and shows the device's real state again.
Only Coil and Holding register points can be written. Discrete input and Input register are read-only.
Reusable alternative: if several cards should write the same points, create a data destination instead (menu → Data destinations → Add data destination, Type Modbus, the same connection and points), then add Trigger data destination on tap with Text to send set to {"setpoint": 25}. See Data destinations (outgoing).
To see the new value right away, add Trigger data source(s) → PLC values after the send. It reads the points once.
Your tap actions, in order:
| Category | Action | Role |
|---|---|---|
| Data actions | Modbus send | Writes 25 to the setpoint point |
| Data actions | Trigger data source(s) | Optional: reads the points again right away |
Troubleshooting
If the card stays empty or shows an error, open Modbus connections → My PLC and check the status dot and the Connection log. On the "Data sources" screen, the source row shows the error of the last read.
- Values look wrong. A 32-bit or 64-bit value shows an absurd number (
3.4e+38,1.2e-41, a huge integer) while 16-bit values look right: change Word order on the connection, or on that point only. CDAB is common on PLCs; the device manual says which one. Values from the neighboring register, or an error on the last register: check Address base. If the manual numbers holding registers 40001, 40002, …, set Address base to 1-based (as in the device manual) and type the number without the table digit: 40001 →1, 40101 →101. Changing the base later shifts every point by one. - "Illegal data address". The device answered, but that table has no register at that address on that unit. The error names the table and the range, for example
Holding registers 100–103: Illegal data address (02). Check the point's Table, Address, and Data type (a Float32 takes 2 registers), the Address base, and the Unit ID. Illegal function means the device does not support that table. - No answer, or "timed out". Check Host, Port, and Unit ID (behind a gateway, the address of the device behind it). Make sure your iPhone or iPad is on the same network, the computer's firewall lets a simulator's port through, and Local Network access is on for Routix Dash in the iOS Settings app. Raise Timeout (ms) for a slow device. Set Min gap between requests (ms) to 20–100 ms for a gateway that drops requests sent back to back.
Gateway target device failed to respond (0B)orGateway path unavailable (0A)means the gateway answered but the device behind it did not: check the Unit ID and the device's serial link. Test counts these as a failure. - The device accepts one connection only. Many PLCs allow one client at a time. Routix Dash uses one link per Modbus connection for all its sources, destinations, and sends, so create only one connection per device, and close other Modbus tools while you test. Test opens its own short link: if it fails while the connection is open, turn Keep connected off and test again.
- The connection shows disconnected between reads. Many devices close a quiet link after 10–60 seconds. That's normal: the next read or write connects again at once. The Connection log shows "Closed by the device while idle".
- The connection keeps reconnecting. After an error, the app tries again after about 1 second, then waits twice as long each time, up to 30 seconds. The wait starts over only after the link has stayed up for 60 seconds. Three requests in a row without an answer close the link and reconnect; the Connection log shows "No answer to 3 requests in a row". An error reply from the device, such as
Illegal data address (02)orGateway target device failed to respond (0B), keeps the link open. A write or Read now tries again at once.
What you built
| Part | Role |
|---|---|
| Modbus connection | Shared link to your device: host, port, Unit ID |
| Modbus TCP data source | Reads temperature and setpoint every second into value |
| Card | A Label shows value?.temperature |
| Modbus send | Writes a new setpoint on tap |
Next steps
- Data sources (incoming) — points, data types, word order, address base, and errors
- Data destinations (outgoing) — reusable Modbus writes
- Tap actions — Modbus send, and Connect / Disconnect for on-demand links
- Components — gauges with warning and alarm zones, alarm banners, and charts
- Get started: MQTT — devices that publish to an MQTT broker