Replacing Obsolete Industrial PLC I/O with an ESP32 and Modbus TCP Bridge
Older industrial machines keep running for decades, but their PLC I/O cards don't always survive that long. When a 20-year-old discrete I/O module dies and the original manufacturer has discontinued the part โ or wants four figures for a replacement that's just a relay and a handful of optocouplers โ an ESP32 bridging the gap over Modbus TCP is often a faster, cheaper, and more maintainable fix than hunting eBay for a surplus card. This isn't a replacement for the PLC itself; it's a way to keep a working PLC's control logic intact while modernizing the failed I/O layer underneath it.
Where This Approach Fits
This technique makes sense when:
- The PLC's CPU and control logic are fine, but a specific I/O card or rack slot has failed
- The failed card uses simple discrete or analog signals (digital in/out, 4โ20mA or 0โ10V analog) rather than a proprietary high-speed backplane protocol
- The PLC itself, or a separate SCADA/HMI layer, can poll a Modbus TCP device โ which the overwhelming majority of mid-size industrial PLCs from the last 20+ years can, even older models, usually via an add-on Ethernet/Modbus TCP card
It does not fit replacing an entire PLC CPU, high-speed motion/servo I/O, or any safety-rated I/O (emergency stop circuits, light curtains, safety relays) โ those require certified hardware, not a hobbyist bridge, full stop.
Parts and Topology
- ESP32 dev board (any variant with enough GPIO for your I/O count)
- Opto-isolated input modules matched to your field voltage (commonly 24VDC in industrial control cabinets)
- Relay output modules or solid-state relays sized to the load you're switching
- A 24V-to-5V (or 3.3V) DC-DC buck converter to power the ESP32 from existing control-cabinet power
- DIN rail mounting hardware and a terminal block to match your cabinet's existing wiring conventions
The ESP32 runs a Modbus TCP server (slave) using a library such as ModbusIP_ESP8266/ESP32 or eModbus, exposing your discrete inputs, discrete outputs, and any analog channels as standard Modbus registers โ discrete I/O as coils, analog as holding registers. The PLC (or an HMI, or a SCADA package like Ignition) then polls the ESP32 exactly as it would poll any other Modbus TCP I/O rack, because from the network's point of view, that's exactly what it is.
Register Mapping: Keep It Boring and Documented
The biggest long-term risk with a bridge like this isn't the hardware โ it's a future technician (possibly you, in two years, having forgotten the details) not knowing what any given register means. Build the map deliberately:
| Modbus Address | Function | Field Signal |
|---|---|---|
| Coil 0โ7 | Discrete Inputs 1โ8 | 24VDC sensors, limit switches, etc. |
| Coil 100โ107 | Discrete Outputs 1โ8 | Relay-driven 24VDC loads |
| Holding Reg 0โ3 | Analog Inputs 1โ4 | 4โ20mA loop, scaled to engineering units in firmware |
Print this table and tape it inside the cabinet door. Label-maker tape on the terminal block, matched to the same numbering, turns a confusing bridge into a transparent one โ this matters far more than any amount of firmware polish.
Reliability Considerations
- Watchdog behavior: decide explicitly what happens to each output if the ESP32 loses network connectivity or power โ fail-safe (de-energized) is almost always the right default for anything mechanical.
- Polling rate: most PLC Modbus polling is forgiving (hundreds of ms to seconds), which plays to an ESP32's strengths; don't try to use this bridge for anything that needs millisecond-class determinism.
- Isolation: use real opto-isolated input modules rather than wiring field 24V directly into ESP32 GPIO โ a single wiring mistake on an unisolated input can take out the whole board, and in an industrial cabinet, field wiring mistakes happen.
- Power supply quality: control cabinets are electrically noisy environments; use a proper DIN-rail DC-DC converter with real input filtering rather than a bare buck module dangling on wires.
Safety
This is a maker-grade solution for maker-grade stakes โ a hobby CNC's limit switches, a shop's non-safety status indicators, a home automation tie-in to an old building system. It is not appropriate anywhere a failure could hurt someone: machine safety circuits, anything on an E-stop chain, or any application where your local electrical code or industrial safety standards (NFPA 79, etc.) require certified, listed hardware. If you're not certain which category your application falls into, treat it as the safety-critical one and don't substitute a hobby board for certified I/O.
Done carefully, with a clearly documented register map and a sane fail-safe default, this kind of bridge has kept more than one otherwise-obsolete machine running for the cost of an ESP32 and an afternoon, instead of a four-figure replacement card that may not even still be manufactured.