Technimal

E02 Modbus I/O Module

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

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

1. Overview

The E02 Modbus I/O Module is an ESP32-based industrial I/O device with 2 configurable analog/digital inputs and 1 PWM output. 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.

2. Key Features

I/O

  • 2× inputs, each: Digital, 4–20 mA, or 0–10 V
  • 1× output via PWM (0–100 %)
  • 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

  • Configurable fail-safe output on link/master loss
  • Output OFF at boot until first write
  • 4–20 mA wire-break detection

3. Specifications

ParameterValue
MCUESP32-WROOM-32U V2.1 (Xtensa dual-core, no PSRAM)
Flash4 MB (DIO, 40 MHz)
Firmwaree02_modbus v1.0.0, built on ESP-IDF 5.4
Inputs2 × (Digital / 4–20 mA / 0–10 V), software-selectable per channel
Output1 × PWM, 1 kHz, 12-bit duty, 0–100 %
Ethernet10 Mbps, full-duplex
SerialRS-485 half-duplex, auto-direction transceiver (no DE/RE pin)
ADC12-bit, ADC1, 12 dB attenuation, 16-sample averaging
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
25Digital input 1
26Digital input 2
36Voltage input 10–10 V (ADC1_CH0)
34Voltage input 20–10 V (ADC1_CH6)
39Current input 14–20 mA (ADC1_CH3)
35Current input 24–20 mA (ADC1_CH7)
4OutputPWM (LEDC)

Each logical input has 3 physical pins (digital / voltage / current); the active pin is chosen by the channel's mode register.

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

Each input's mode is set by its mode register (0=Digital, 1=4–20 mA, 2=0–10 V). Values are reported over Modbus in engineering units:

ModeReported valueExample
Digital0 / 1 (debounced, 3 consistent reads @ 10 ms)1 = high
4–20 mAcenti-mA (mA × 100)2000 = 20.00 mA
0–10 Vcenti-volt (V × 100)1000 = 10.00 V

In 4–20 mA mode a reading below ~3.5 mA sets the wire-break status flag.

5.2 Output

The output register holds a duty percentage 0–100, driven on a 1 kHz PWM. Writes take effect immediately. At boot and during fail-safe the output is forced to a defined value (default 0 %).

6. Network & Discovery

TXT records (capability advertisement):

KeyExampleMeaning
modele02_modbusDevice model
fw1.0.0Firmware version
i2Input channels
o1Output 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
1Input 1 modeR/WNVS0=Dig, 1=4–20 mA, 2=0–10 V
2Input 2 modeR/WNVSsame
3Fail-safe output valueR/WNVSpercent 0–100
4Fail-safe timeout (s)R/WNVS0 = disabled
5RTU enableR/WNVS0/1; effective after reboot
6RTU baud / 100R/WNVS96=9600 … 1152=115200
7RTU parityR/WNVS0=none, 1=odd, 2=even
8RTU stop bitsR/WNVS1 or 2
9Input 1 valueRscaled (see §5.1)
10Input 2 valueRscaled (see §5.1)
11OutputR/WPWM percent 0–100
12Status flagsRbitfield (below)

Status flag bits (register 12)

BitMaskMeaning
00x01Ethernet link / IP up
10x02Modbus master polled recently (any transport)
20x04Input 1 wire-break (4–20 mA < 3.5 mA)
30x08Input 2 wire-break
40x10Output forced to fail-safe
50x20RTU transport enabled

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 output (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–8) with FC 06. Config values persist to NVS. Transport/serial params (unit id, RTU baud/parity/stop/enable) apply on the next reboot; input modes, output and fail-safe values 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, input modes, fail-safe, 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. Managed components (esp-modbus v2.x, mdns, enc28j60) download on first build.

idf.py set-target esp32
idf.py build
idf.py -p /dev/ttyUSB0 flash monitor

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

13. Calibration

The analog scaling constants in main/config.h are placeholders and must be calibrated per hardware revision before field use:
ConstantMeaning
ADC_MV_AT_FULL_VOLTADC millivolts when the 0–10 V terminal reads 10.00 V (divider ratio)
CURRENT_SENSE_OHMSRS sense resistor: I(mA) = Vadc(mV) / R
CURRENT_WIRE_BREAK_CMAwire-break threshold in centi-mA (default 350 = 3.5 mA)

Recommended: 2-point calibration per mode (e.g. apply 4 mA & 20 mA, 0 V & 10 V) and adjust the constants so reported values match a reference meter.

14. 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 5); matching baud/parity/stop & slave address; A/B lines & ground; UART2 = GPIO17/16
Analog values wrongCalibrate ADC_MV_AT_FULL_VOLT / CURRENT_SENSE_OHMS; verify input mode register
Output only 0 % / 100 %Write percent 0–100 to register 11; 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