This template connects a generic, unbranded Modbus RTU I/O module with 8 digital outputs and 8 digital inputs to TapHome over RS-485. It creates eight Switch devices (DO1–DO8) and eight Reed contact devices (DI1–DI8). The template has no fixed manufacturer or model: it fits only a module whose register table matches the layout described below, so the register table of the module has to be checked before the template is used.
Before you use this template
The template reads and writes holding registers only (Modbus function 03 for reading, function 06 for writing). It expects this register layout:
| Data | Register type | Register | Content |
|---|---|---|---|
| Outputs DO1–DO8 | Holding | one register, import parameter DO Register | bits 0–7 = state of DO1–DO8 |
| Inputs DI1–DI8 | Holding | one register, import parameter DI Register | bits 0–7 = state of DI1–DI8 |
Many low-cost 8DI/8DO RS-485 modules document their outputs as coils (functions 01, 05, 0F) and their inputs as discrete inputs (function 02), and use holding registers only for configuration. Such a module cannot be controlled by this template without changes. Check in the register table of the module that the outputs are available as a bit mask in one holding register and the inputs as a bit mask in one holding register before the module is installed.
The register type is fixed in the template scripts; only the two register addresses and the Slave ID can be changed at import.
Hardware connection
The module is wired to the RS-485 bus of the TapHome Core:
- A to A, B to B. Terminal labels differ between manufacturers (A/B, A+/B−, D+/D−). If the module does not answer, swap the two wires.
- Common ground: on longer lines, connect the GND of the module to the GND of the bus if the module provides a terminal for it.
- Bus topology: a line bus with termination at both ends. Whether the module has a built-in termination resistor and how it is switched on depends on the module — check it on the module.
- Unique Slave ID: every device on the same RS-485 line needs its own Slave ID.
Check on the module before wiring: supply voltage, input type (dry contact, NPN or PNP, voltage input) and output type (relay or transistor) and their ratings. The template does not depend on these, but the wiring of loads and sensors does.
Configuration
Communication settings on the module
The template suggests these line parameters for the TapHome Modbus RTU interface:
| Parameter | Value |
|---|---|
| Baud rate | 9600 |
| Data bits | 8 |
| Parity | None |
| Stop bits | 1 |
The module has to use the same baud rate and framing, and its Slave ID has to match the import parameter. Where these are set — DIP switches, a configuration register or the manufacturer’s configuration software — depends on the module; check it in the module documentation or on the module itself.
Import parameters
| Parameter | Default | Meaning |
|---|---|---|
| DO Register | 1 | address of the holding register with the output bits |
| DI Register | 2 | address of the holding register with the input bits |
| Slave ID | 1 | Modbus address of the module |
TapHome sends the register address to the module unchanged and counts from 0. If the register table of the module numbers registers from 1 (for example 40001, 40002), subtract 1 — see Modbus register addressing. The IP address import parameter has no effect on a Modbus RTU interface and can stay at its default.
In TapHome, add a Modbus RTU interface with the line parameters above and import the template with the Slave ID and the two register addresses of the module.
Device capabilities
Digital outputs DO1–DO8
Each output is a Switch device. Its state is read every 1000 ms from bit 0 (DO1) to bit 7 (DO8) of the DO Register. Switching is handled by the write script of the TapHome module, not by each output: when any output changes, TapHome writes the bit mask of all eight outputs to the DO Register in one write (function 06), and only when the value changes. Bits 8–15 of the written value are always 0.
Digital inputs DI1–DI8
Each input is a Reed contact device that shows bit 0 (DI1) to bit 7 (DI8) of the DI Register, read every 1000 ms. It suits door and window contacts, float switches or auxiliary relay contacts wired to the inputs of the module.
Check on the module that bit 0 really corresponds to the first channel and that the module accepts a bit mask written with function 06 to the output register.
Troubleshooting
No response from the module
- Check the RS-485 wiring and swap A and B if needed.
- Check that the Slave ID of the module matches the import parameter Slave ID.
- Check that the baud rate, parity and stop bits of the module match the Modbus RTU interface (9600, 8N1 suggested).
- Check the termination at both ends of the bus.
“Illegal data address” error
The register address is shifted by 1 (the module documentation numbers registers from 1), or the module does not have this register layout at all — for example when its outputs are coils and its inputs are discrete inputs. Compare the import parameters with the register table of the module.
Outputs or inputs map to the wrong channels
The bit order of the module differs from the template (bit 0 = channel 1). Check the bit assignment in the register table of the module.