Vertical, industrial process water and OEM skids
Adding remote monitoring beside an existing PLC
Updated
You can add remote monitoring to a running machine without touching its control program: put a separate gateway on the PLC’s Ethernet network, have it read registers the PLC already exposes over Modbus TCP, and send the data out over a connection the gateway opens itself. The gateway never writes, the PLC keeps doing its job if the gateway fails, and nothing on the internet can connect in. Before any of that, get the integrator’s register map and their agreement, because “already exposes” is the part that is often not true.
Why beside, not inside
The PLC runs the process; a monitoring change should not be able to stop it. Changing the control program means a download to a running controller, a new revision the integrator has to support, and often a re-validation. A gateway beside the PLC avoids all three, and it can be removed in five minutes by unplugging it.
The arrangement:
[ PLC ] --- control network (no internet) --- [ gateway eth0 ]
[ gateway eth1 or LTE ] --> outbound TLS --> cloud / phone alerts
The gateway is the only device on both sides, and it routes nothing between them. In IEC 62443 terms the control network is one zone and the gateway is the conduit to the next; NIST SP 800-82 Rev. 3 recommends the same kind of segmentation between OT and other networks.
Does the PLC already speak Modbus TCP?
This is the first question, and the answer decides whether “no program changes” holds:
| Situation | What it means |
|---|---|
| Modbus TCP server is built in and enabled by configuration | Best case. Read the documented registers; no program change. Common on smaller PLCs and many drives, meters and HMIs. |
| Modbus TCP server is a function block in the control program | Exposing data is a program change. On Siemens S7-1200 and S7-1500, the MB_SERVER instruction is called and parameterized in the user program (Siemens application example). If it is already there for an HMI or SCADA, you may be able to read the same registers. |
| PLC speaks only its native protocol | Read with that protocol instead, read-only. For Rockwell Logix controllers over EtherNet/IP, pycomm3 reads tags by name. |
| An HMI or SCADA already polls the PLC | The HMI may itself be a Modbus TCP server with the values you need, which keeps all traffic off the PLC. |
If the only way in is a program change, that is a decision for the owner and the integrator, not a detail to work around.
Read-only is your job, not the protocol’s
Modbus TCP has no authentication. Any client that can reach port 502 can send function 6 or 16 and write a register, and the PLC cannot tell the monitoring gateway from an engineer’s laptop. Read-only has to be enforced from your side, in layers:
- Code. The gateway only calls read functions: 1 (coils), 2 (discrete inputs), 3 (holding registers) and 4 (input registers), from the Modbus application protocol. There are no write calls anywhere in it to misconfigure.
- PLC. Some PLCs can restrict Modbus writes, or limit which registers or clients the server accepts. Ask what this one can do.
- Network. A firewall that understands Modbus can drop write function codes between the gateway and the PLC. Plain port filtering cannot, since reads and writes use the same port.
- No inbound path. Nothing outside can reach the gateway, so nobody can use it as a stepping stone to send writes.
Polling without disturbing the PLC
A PLC handles Modbus requests alongside its control scan. The load from one client is small, but it is not zero, and connection slots are limited.
- One connection, kept open. Opening a new TCP connection per read wastes the PLC’s limited connection slots. Ask how many Modbus TCP connections it allows and how many the HMI and SCADA already use.
- Block reads. Read contiguous registers in one request, up to 125 per read. Fifty values in one request cost the PLC far less than fifty requests.
- Poll as slowly as the process allows. For tank levels and temperatures, 5 to 10 s is typical; alarms that matter in seconds belong in the PLC itself, not in the cloud.
- Measure before and after. Ask the integrator to note the PLC’s scan time and communication diagnostics with the gateway off and on.
This script polls one block read-only, prints the values and reports response times. Run it during commissioning with the integrator present (pymodbus 3.16.2, Python 3.10 or later):
"""Read one block of PLC registers over Modbus TCP, repeatedly, and report values and response times. Never writes."""
import argparse
import statistics
import sys
import time
from pymodbus import ModbusException
from pymodbus.client import ModbusTcpClient
parser = argparse.ArgumentParser()
parser.add_argument("host")
parser.add_argument("--port", type=int, default=502)
parser.add_argument("--unit", type=int, default=1, help="Modbus unit ID; many PLCs ignore it, gateways need it")
parser.add_argument("--address", type=int, default=0, help="zero-based address (40001 is 0)")
parser.add_argument("--count", type=int, default=10, help="registers per read, at most 125")
parser.add_argument("--input", action="store_true", help="input registers (function 4) instead of holding (3)")
parser.add_argument("--reads", type=int, default=20)
parser.add_argument("--interval", type=float, default=1.0, help="seconds between reads")
args = parser.parse_args()
client = ModbusTcpClient(args.host, port=args.port, timeout=2, retries=0)
if not client.connect():
sys.exit(f"cannot connect to {args.host}:{args.port}")
read = client.read_input_registers if args.input else client.read_holding_registers
times_ms, failures = [], 0
try:
for _ in range(args.reads):
started = time.perf_counter()
try:
response = read(args.address, count=args.count, device_id=args.unit)
elapsed_ms = (time.perf_counter() - started) * 1000
if response.isError():
failures += 1
print(f"Modbus exception code {response.exception_code}")
else:
times_ms.append(elapsed_ms)
print(response.registers)
except ModbusException as exc:
failures += 1
print(f"no response: {exc}")
time.sleep(max(0.0, args.interval - (time.perf_counter() - started)))
finally:
client.close()
if times_ms:
print(f"{len(times_ms)} good reads, {failures} failed; response median {statistics.median(times_ms):.1f} ms, max {max(times_ms):.1f} ms")
else:
print(f"0 good reads, {failures} failed")
python3 -m venv ~/plc && ~/plc/bin/pip install pymodbus==3.16.2
~/plc/bin/python plc_read_test.py 192.168.10.20 --address 0 --count 20 --reads 30 --interval 2
Compare the values with what the HMI shows. If a value is off by one register, the map uses 1-based numbering (40001 is address 0). If a 32-bit value is absurd, the word order is swapped. For continuous polling with MQTT output and alarms, use the Modbus gateway (its TCP side is not needed here) or the modbus_tcp source in Modbus or MQTT value to alarm.
Network setup on the gateway
Give the control-network interface a static address and no default gateway, so the gateway cannot route anything from the control network outward. Turn off IP forwarding (net.ipv4.ip_forward = 0, the Debian default). Then let the gateway talk only to the PLC on that side. With nftables, in /etc/nftables.conf:
#!/usr/sbin/nft -f
flush ruleset
table inet monitor {
chain input {
type filter hook input priority filter; policy drop;
iif "lo" accept
ct state established,related accept
meta l4proto { icmp, ipv6-icmp } accept
}
chain forward {
type filter hook forward priority filter; policy drop;
}
chain output {
type filter hook output priority filter; policy accept;
oifname "eth0" ip daddr 192.168.10.20 tcp dport 502 accept
oifname "eth0" drop
}
}
eth0 faces the PLC (here at 192.168.10.20). The input chain accepts only replies to connections the gateway opened, plus ICMP so that IPv6 neighbour discovery and path MTU discovery keep working; nothing can connect in on either interface. Add an explicit rule if you need SSH from a maintenance laptop. Enable with sudo systemctl enable --now nftables. Syntax follows the nftables quick reference.
On the internet side, use outbound connections only: MQTT over TLS or HTTPS to your cloud service. The joint CISA, FBI, EPA and DOE guidance of May 2025 puts removing OT internet exposure and segmenting IT from OT first among its five mitigations. A gateway with no open ports and no route between its interfaces does both.
Prefer a cellular connection or a separate internet line over the plant’s office network if IT cannot give you an isolated VLAN. It keeps the monitoring path independent of the office, and the office out of the control network.
What to ask the integrator
Send these before the site visit:
- Does the PLC have a Modbus TCP server today, and is it enabled? If not, what would it take?
- The register map: address, data type (16-bit, 32-bit, float), word order, scaling, units and engineering meaning for each value you want. Is the numbering 0-based or 1-based?
- Which unit ID should we use?
- How many Modbus TCP connections does the PLC allow, and how many are in use by the HMI and SCADA?
- Can the PLC restrict Modbus writes, or the registers a client can reach? Would you enable that?
- Is there a free switch port on the control network, and an IP address we can use? What else is on that network?
- Where can the gateway be mounted, and can it take 24 V DC from the panel supply? Does adding it affect the panel’s listing, for example UL 508A?
- Does connecting anything to the network affect your warranty or support agreement?
- Who must approve the change, and how is it recorded in the site’s change management?
- Which values already raise alarms in the PLC or HMI? Remote alarms should duplicate or extend those, not contradict them.
- Who do we call if the PLC behaves differently after the gateway is connected?
What halfnine will offer here
To be decided: whether the halfnine controller and supervisor will support read-only polling of an existing PLC, which protocols, and how it enforces read-only. Until then, the setup above works with any Linux gateway.
Sources
- Modbus Organization, specifications (Modbus Application Protocol V1.1b3, Messaging on TCP/IP Implementation Guide), accessed 2026-11-19
- NIST SP 800-82 Rev. 3, Guide to Operational Technology (OT) Security (2023), accessed 2026-11-19
- ISA/IEC 62443 series of standards, accessed 2026-11-19
- CISA, FBI, EPA, DOE, Primary Mitigations to Reduce Cyber Threats to Operational Technology (May 2025), accessed 2026-11-19
- Siemens application example, Modbus/TCP communication S7-1500 and S7-1200 (entry 102020340), accessed 2026-11-19
- pycomm3 on PyPI (EtherNet/IP client for Rockwell Logix, version 1.2.16), accessed 2026-11-19
- pymodbus on PyPI (version 3.16.2), accessed 2026-11-19
- nftables quick reference, accessed 2026-11-19