> ## Documentation Index
> Fetch the complete documentation index at: https://docs.bijection.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Modbus TCP

> Poll one sealed input or holding-register range on a private Modbus TCP socket.

Install the app on a self-hosted deployment with direct, policy-approved network
access to a private RFC 1918 IPv4 address. Modbus TCP carries the register
request and values unencrypted on that network. The closed driver requires
a private address literal and uses the deployment's socket egress authority.
Hosted tenant egress refuses private socket addresses. Private-only
sites need a direct route from their self-hosted deployment.

```ts app.ts theme={"theme":{"light":"github-light-default","dark":"github-dark-default"}}
import { app, label, secret } from "@bijectionhq/bijection";
import modbus, { modbusEndpoint } from "@bijectionhq/app-modbus";

const readings = label();
const scope = secret();
const meter = modbusEndpoint("10.24.1.5:502", scope, readings);

export default app({ readings, scope, meter, plant: modbus({ data: readings, provider: meter }) });
```

```sh theme={"theme":{"light":"github-light-default","dark":"github-dark-default"}}
bijection secret set scope --from-file selection.json
bijection mutate plant.source.initialize '{"selection": {"unit": 7, "table": "input", "start": 16, "count": 2}}'
```

`plant.operator` is granted from code: `ctx.grant(plant.operator, { to, under })` in one of your
mutations ([Grants](https://docs.bijection.com/access/grants.md)).

Set the secret to the exact register selection JSON. The sealed selection
limits the allowed poll, and no credentials travel to the device. The
receiver and the mount live under the same `data` label, and the mount's
`operator` role, which clears it, is the only role that starts the source or
reads `plant.records.list` and `plant.source.health`.

Use units 1–247, zero-based addresses 0–65535, and a range of 1–64 words
within the address space. The profile uses function 3 for holding registers
and function 4 for input registers. Each poll opens a fresh connection,
sends one read and accepts one matching reply within five seconds. The app
replaces the last observation by unit, register table and address. It keeps
each raw unsigned 16-bit word and the poll admission time. There is no
provider cursor, write operation, archive or deletion inference. A failed
poll preserves the last readings.

[Modbus protocol specifications](https://www.modbus.org/modbus-specifications)


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.