Technimal

E04 Modbus I/O Module

ESP32-based 4-input / 4-output digital module · Modbus TCP & RTU · mDNS discovery
Model: e04_modbus FW 1.0.0 ESP32-WROOM-32U V2.1 Ethernet + RS-485 ESP-IDF 5.4

Datasheet & User Manual · Board owledge (MODEL E04SD) · Document rev 1.0 · 2026-06-18

1. Overview

The E04 Modbus I/O Module is an ESP32-based industrial I/O device with 4 digital inputs and 4 digital outputs. It is exposed simultaneously over Modbus TCP (Ethernet) and Modbus RTU (RS-485), sharing one register map, and is discoverable on the LAN via mDNS / Zeroconf. A supervisory platform browses mDNS, reads capability metadata from TXT records, then polls/controls the device — no static IP or manual register-map documentation required for integration.

The E04SD is the all-digital sibling of the E02 module (2 analog/digital in, 1 PWM out). Both run the same firmware, selected at build time by a Kconfig board choice.

2. Key Features

I/O

  • digital inputs (debounced)
  • digital outputs (on/off)
  • Single-colour status LED

Connectivity

  • Modbus TCP over Ethernet, port 502
  • Modbus RTU over RS-485 (concurrent)
  • mDNS service advertisement
  • DHCP client (static IP optional)

Configuration

  • All params via Modbus registers
  • NVS persistence (survives reboot)
  • SoftAP web portal for provisioning

Safety

  • Per-output fail-safe state (bitmask) on link/master loss
  • All outputs OFF at boot until first write

3. Specifications

ParameterValue
MCUESP32-WROOM-32U V2.1 (Xtensa dual-core, no PSRAM)
Flash4 MB (DIO, 40 MHz)
Firmwaree04_modbus v1.0.0, built on ESP-IDF 5.4
Inputs4 × digital, debounced (3 consistent reads @ 10 ms)
Outputs4 × digital (on/off, push-pull GPIO)
Ethernet10 Mbps, full-duplex
SerialRS-485 half-duplex, auto-direction transceiver (no DE/RE pin)
ProtocolsModbus TCP (port 502) + Modbus RTU, concurrent; mDNS
AddressingDHCP client; static IP fallback configurable

4. Pinout

4.1 Board I/O

ESP32 GPIOFunctionNotes
12Status LEDsingle colour; strapping pin (MTDI) — driven after boot
14Config-mode buttonhold LOW at boot → provisioning
39Digital input 1input-only pin (external pull on board)
36Digital input 2input-only pin (external pull on board)
35Digital input 3input-only pin (external pull on board)
34Digital input 4input-only pin (external pull on board)
25Digital output 1
26Digital output 2
27Digital output 3
4Digital output 4
Inputs are on GPIO 34–39, which are input-only and have no internal pull-up/down. The board must provide external pull resistors on each input line.

4.2 Ethernet — ENC28J60 (SPI)

ESP32 GPIOENC28J60
5CS
18SCLK
19MISO
23MOSI
N/AINT (not connected — driver runs in polling mode)

4.3 RS-485 — Modbus RTU (UART2)

ESP32 GPIOFunction
17UART2 TX → RS-485 transceiver
16UART2 RX ← RS-485 transceiver
N/ADE/RE — none (auto-direction transceiver)

5. I/O Channels

5.1 Inputs

All 4 inputs are digital. Each is debounced (3 consistent reads at a 10 ms poll interval) and reported over Modbus as 0 / 1 in its input register.

5.2 Outputs

Each of the 4 outputs is driven from its output register: any non-zero value drives the GPIO high (ON), zero drives it low (OFF). Writes take effect immediately. At boot and during fail-safe the outputs are forced to a defined state.

6. Network & Discovery

TXT records (capability advertisement):

KeyExampleMeaning
modele04_modbusDevice model
fw1.0.0Firmware version
i4Input channels
o4Output channels
unit1Modbus unit/slave ID
protomodbus-tcpProtocol identifier
macB4E62DDE225DWiFi MAC (no colons)

7. Modbus Interface

ParameterTCPRTU
RoleSlave / Server (both run concurrently, shared registers)
TransportEthernet, port 502RS-485, UART2
AddressUnit ID (MBAP)Slave address = Unit ID register
Default line9600 baud, 8N1 (configurable)
Function codes03 (read holding), 06 (write single holding)
Byte orderBig-endian (standard Modbus)

RTU baud / parity / stop-bits and the unit/slave id take effect after a reboot (the Modbus controllers are created once at startup).

8. Register Map (Holding Registers)

Read with FC 03, write with FC 06. Layout: configuration block first, then live I/O.

AddrRegisterAccessPersistNotes
0Unit ID / RTU addressR/WNVS1–247; effective after reboot
1Fail-safe output bitmaskR/WNVSbits 0–3 → outputs 1–4
2Fail-safe timeout (s)R/WNVS0 = disabled
3RTU enableR/WNVS0/1; effective after reboot
4RTU baud / 100R/WNVS96=9600 … 1152=115200
5RTU parityR/WNVS0=none, 1=odd, 2=even
6RTU stop bitsR/WNVS1 or 2
7Input 1 valueR0 / 1 (debounced)
8Input 2 valueR0 / 1
9Input 3 valueR0 / 1
10Input 4 valueR0 / 1
11Output 1R/W0 = OFF, non-zero = ON
12Output 2R/W0 / 1
13Output 3R/W0 / 1
14Output 4R/W0 / 1
15Status flagsRbitfield (below)

Status flag bits (register 15)

BitMaskMeaning
00x01Ethernet link / IP up
10x02Modbus master polled recently (any transport)
40x10Outputs forced to fail-safe
50x20RTU transport enabled

Bits 2–3 (wire-break) are defined in the shared register layout but are only meaningful on the E02 (4–20 mA) variant; they read 0 on the E04.

9. Status LED (GPIO 12)

StateLEDMeaning
ProvisioningFast blinkConfig mode (SoftAP portal active)
InitializingSlow blinkBooting, network not ready
RunningSolid ONNormal operation (Modbus serving)

10. Fail-safe & Boot

Boot sequence: init GPIO + safe outputs (LED slow-blink) → bring up Ethernet, acquire DHCP → start mDNS + Modbus TCP/RTU slaves (LED solid) → enter input-poll loop.

11. Configuration (Manual)

11.1 Via Modbus

Write configuration registers (0–6) with FC 06. Config values persist to NVS. Transport/serial params (unit id, RTU baud/parity/stop/enable) apply on the next reboot; fail-safe bitmask/timeout and the outputs apply live.

11.2 Via SoftAP web portal (provisioning)

  1. Hold GPIO 14 LOW at power-on/reset — the LED blinks fast.
  2. Join WiFi AP E02-xxxxxx (password edge12345).
  3. Open http://192.168.4.1/ and set unit id, fail-safe (outputs bitmask / timeout), RS-485 (enable/baud/parity/stop) and optional static IP.
  4. Save → settings persist to NVS and the device reboots into normal operation.
Security: Modbus is unauthenticated (per the standard). Deploy only on trusted networks. Change the default SoftAP password per site policy.

12. Build & Flash

Toolchain: ESP-IDF v5.4, target esp32. The E04SD variant is a compile-time Kconfig choice (CONFIG_BOARD_E04SD=y, in sdkconfig.e04sd). Managed components (esp-modbus v2.x, mdns, enc28j60) download on first build.

idf.py set-target esp32
idf.py -B build_e04 -DSDKCONFIG=sdkconfig.e04 \
       -DSDKCONFIG_DEFAULTS="sdkconfig.defaults;sdkconfig.e04sd" build
idf.py -B build_e04 -p /dev/ttyUSB0 flash monitor

Binary ~979 KB; factory partition 3.88 MB (4 MB flash, no OTA).

13. Troubleshooting

SymptomCheck
No IP / not discoverableEthernet cable & ENC28J60 wiring (CS5/SCLK18/MISO19/MOSI23); DHCP server present; LED stuck slow-blink = no IP yet
TCP master can't connectConfirm IP (serial log), port 502 open, only the needed master polling
RTU no responseRTU enabled (reg 3); matching baud/parity/stop & slave address; A/B lines & ground; UART2 = GPIO17/16
Input always 0 or 1GPIO 34–39 need external pull resistors; verify field wiring & signal level
Output doesn't switchWrite to registers 11–14; check fail-safe isn't active (status bit 4)
Can't enter config modeGPIO14 must read LOW at boot; LED should switch to fast blink