This paper describes the circuit and firmware of a ground-fault locator for a 24 V line that uses no resistor ladder and no analog measurement. Four transmit optocouplers energise four phase lines one at a time. A 4×4 matrix of series diode and switch pairs connects each phase line to four distance columns, and each column drives a receive optocoupler’s LED. An ESP32 reads the four receive outputs as digital levels, so the phase is given by the energised line and the distance by the conducting column.
The 24 V and 3.3 V domains use separate grounds and are joined only through optocouplers, which was confirmed from the netlist. The ESP32 also creates its own WiFi access point and serves a status page from its LittleFS flash file system, so no router or internet connection is needed.
Analysis of the schematic gives 9.5 mA of transmit LED current, 4.7 mA of receive LED current, a receive logic-low level of about 0.2 V against a limit near 0.8 V, a 32 ms matrix scan, and a worst-case display latency of about 1.1 s. The design is validated analytically; bench measurements on a built prototype remain future work.
Introduction
The text presents the design of an Arduino/ESP32-based ground fault locator for 24 V power cables. The system identifies the faulty phase and estimates the fault location using a 4×4 diode matrix, optocouplers, and a Wi-Fi-based web interface.
1. Introduction
Locating ground faults in buried cables is difficult because repair crews may otherwise need to excavate the entire cable route. Traditional resistance-based methods have limitations, including ADC measurement errors, dependence on resistor tolerances, shared grounding, and the need for an internet connection.
The proposed system addresses these issues by using digital fault detection, electrical isolation, and a locally hosted web interface.
2. System Architecture
A 24 V supply powers four phase lines: PH_A, PH_B, PH_C, and PH_N.
A 4×4 diode matrix represents four phases and four distance points.
Eight PC817-class optocouplers provide signal transfer between the 24 V circuit and the 3.3 V ESP32 circuit.
The ESP32 scans the matrix, identifies the fault, and displays the information on an LCD.
A smartphone or computer connects directly to the ESP32's Wi-Fi network to view fault information.
3. Circuit Design
The circuit consists of three main sections:
Transmit stage: Four optocouplers activate one phase at a time. Each LED uses a 220 Ω resistor, producing approximately 9.5 mA of LED current.
Diode matrix: Sixteen diodes and switches represent possible faults at different phase and distance combinations. The diodes prevent unwanted current paths and false detections.
Receive stage: Four optocouplers detect current flowing through the matrix. Their outputs produce digital signals that the ESP32 reads to identify the fault.
The receive stage uses 4.7 kΩ resistors and 10 kΩ pull-up resistors to establish suitable operating currents and logic levels.
4. Electrical Isolation and Grounding
The system maintains separate grounds for the 24 V circuit and the ESP32 circuit. Optocouplers transfer signals between these domains without a direct copper connection.
The design analysis checks the isolation arrangement, LED currents, resistor power dissipation, current transfer ratios, and ESP32 input logic levels to ensure reliable operation.
5. Firmware and Fault Detection
The ESP32 scans each phase sequentially. It activates a phase, waits 3 milliseconds, and reads the four receive signals. Each phase is checked twice, and the readings are combined to reduce false detections caused by noise.
The firmware identifies the conducting matrix crossing and reports the corresponding phase and distance. It also stores the complete matrix state for display.
6. Wi-Fi Web Interface
The ESP32 operates as a password-protected Wi-Fi access point with a maximum of four connected clients. It hosts its own web server, so an external internet connection is unnecessary.
The web page, stored in LittleFS, displays:
Fault status, phase, and estimated distance.
A visual representation of the 4×4 matrix.
System uptime and the latest ten fault events.
The page updates its status information every second and is read-only, preventing users from changing the monitored line's state.
Conclusion
Finding the position of a ground fault on a cable is difficult when the cable is buried, because repair crews must otherwise dig along the whole route. Methods for locating faults in shielded power cables are surveyed in IEEE Std 1234 [1], and the classical resistive methods are covered in power-system texts such as [2].
A public Arduino and IoT project [3] models the cable as a chain of series resistors. A ground fault changes the resistance seen by the source, an ADC measures the resulting voltage, and a cloud service shows the result. This approach has three drawbacks for a 24 V line. The ADC of a 3.3 V controller cannot accept the sense voltage without an attenuator, and the ESP32 ADC is non-linear near the ends of its range [4]. The distance resolution depends on resistor tolerance. The controller also shares a ground with the line, and the display needs an internet connection.
The design in this paper removes all three. Phase and distance are encoded by which crossing of a matrix conducts, so the readout is digital. Optocouplers carry every signal across the barrier between the 24 V line and the ESP32. The ESP32 hosts the user interface itself, as a web page on its own WiFi network. The main contributions are: (i) a schematic for a 4×4 diode-matrix locator with eight optocouplers; (ii) a check from the netlist that the two ground domains are separate; (iii) an access-point web interface served from LittleFS; and (iv) an analytical evaluation of currents, logic levels, timing and resource use.
II. SYSTEM ARCHITECTURE
Fig. 1 shows the system. A 24 V supply feeds four transmit optocouplers (U1 to U4), one per phase line. The phase lines enter a 4×4 matrix. Its four columns each end at a receive optocoupler (U5 to U8). The ESP32 (U9) drives the LEDs of U1 to U4 and reads the outputs of U5 to U8, and it drives an IZC character LCD (J1). A phone or computer joins the ESP32 WiFi network and opens the status page.
The four phase lines are named PH_A, PH_B, PH_C and PH_N, the four columns DIST1 to DIST4, and the ESP32 signals TX_A to TX_N and RX_1 to RX_4. The same names appear in the schematic of Fig. 2 and in the exported netlist.
Fig. 1. System block diagram. Only optocouplers cross between the 24 V side and the 3.3 V side.
III. CIRCUIT DESIGN
Fig. 2 shows the matrix part of the circuit. The ESP32 and LCD connections are listed in Table I instead of being drawn, so that the schematic stays easy to read.
Fig. 2. Schematic of the optocoupler matrix. Red parts are on the 24 V side and blue parts on the ESP32 side. Each of the 16 crossings is a series diode (D1 to D16) and switch (SW1 to SW16). The ESP32 signals TX_x and RX_n are listed in Table I.
A. Transmit Stage
Each TX optocoupler (U1 to U4, PC817 class) has its LED driven from an ESP32 pin through a 220 fi resistor (R1 to R4) to GND_ESP. Its phototransistor collector is tied to +24 V and its emitter forms the phase line. Neglecting the pin output drop, the LED current is
ITX = (VDD ? VF) / RTX (1)
With VDD = 3.3 V, VF = 1.2 V and RTX = 220 fi, ITX = 9.5 mA, well under the 40 mA absolute maximum of an ESP32 pin [4]. Only one TX pin is high at a time.
B. Matrix and Series Diodes
Phase line p connects to column d through a series diode and switch. The diode (1N4148) has its anode on the phase line. In the bench model each switch is a push button that stands for a ground fault at that phase and distance. If SWpd is closed and phase p is energised, current flows from the phase line through the diode and switch into column d. The detection rule is
F(p, d) = [phase p on] ? [RXd low] (2) where F(p, d) = 1 means a ground fault on phase p at distance d.
The diodes stop false readings when several switches are closed. Suppose SW at (p, d), (p?, d) and (p?, d?) are all closed, with only phase p energised. Without diodes, current could run from column d back through phase line p? and out through column d?, so RXd? would read low although no switch is closed at (p, d?). The diode in each branch blocks current from a column back into a phase line. The unenergised phase lines also float, because their TX phototransistors are off.
C. Receive Stage
Each column ends in a 4.7 kfi resistor (R5 to R8) that sets the current through the LED of a receive optocoupler (U5 to U8). The LED cathode returns to GND_24V. The receive phototransistor has its emitter on GND_ESP and its collector on a net RX_n, which has its own 10 kfi pull-up (R9 to R12) to 3.3 V and goes to an ESP32 input. The RX LED current is
IRX = (VL ? VF,LED ? VD ? VCE,sat) / RRX (3)
With VL = 24 V, VF,LED = 1.2 V, VD = 0.7 V, VCE,sat = 0.2 V and RRX = 4.7 kfi, IRX = 4.7 mA. The power in each of R5 to R8 is 0.10 W, inside a 0.25 W rating.
The pull-up current when the receive transistor is off is small, and when it is on the transistor must sink it. The ESP32 internal pull-up (nominally 45 kfi) is in parallel with RPU, so
IPU = VDD / (RPU ? Rint) = 0.40 mA (4)
An RX optocoupler with a current transfer ratio CTRRX of at least 50 % produces at least 0.5 × 4.7 mA = 2.3 mA, which is 5.8 times IPU. The logic-low level is then about VCE,sat = 0.2 V, below the input-low limit of roughly 0.25 VDD = 0.8 V for an ESP32 pin [4].
D. Isolation and Grounding
The schematic uses two ground nets. GND_24V holds the return of the 24 V supply and the cathodes of the RX LEDs. GND_ESP holds the ESP32, the LCD, the TX LED cathodes and the RX emitters. A script over the exported netlist lists the parts that have pins on both nets, and the result is U5, U6, U7 and U8 only. Each of these is an optocoupler whose LED is on GND_24V and whose emitter is on GND_ESP, so no copper path joins the two grounds. A PC817-class part has a collector-emitter rating of 80 V and a nominal isolation voltage of 5 kVrms [5]. The TX optocouplers also cross the barrier, with the collector at +24 V and the LED on GND_ESP.
The TX stage must supply IRX, so the required transfer ratio is
CTRTX ? IRX / ITX = 0.49 (5)
This is met by the 50 % minimum of common PC817 grades, with little margin. Because the RX stage needs only 0.40 mA to switch (4), a lower TX collector current reduces IRX but does not stop detection.
TABLE I
ESP32 PIN MAP AND PASSIVE VALUES
Signal ESP32 pin Part / value
TX_A, TX_B, TX_C, TX_N GPIO 25, 26, 27, 33 R1 to R4, 220 fi
RX_1 to RX_4 GPIO 16, 17, 18, 19 R9 to R12, 10 kfi
SDA, SCL (J1 LCD) GPIO 21, 22 IZC, 0x27
Column resistors none R5 to R8, 4.7 kfi
Crossing diodes none D1 to D16, 1N4148
IV. FIRMWARE AND WEB INTERFACE
A. Matrix Scan
For each phase, the firmware sets the TX pin high, waits 3 ms for the optocoupler to settle, reads the four RX pins (low means conducting), and sets the pin low again. Each phase is read twice and the two readings are combined with a logical AND so that one noisy read cannot produce a fault. The first phase with a conducting column is reported, and within it the nearest column. The full 4×4 state is also stored for the web page.
B. Access Point and Web Server
The ESP32 is set to access-point mode with a WPA2 password, address 192.168.4.1 and at most four clients. A small DNS server answers every name with the ESP32 address, so a phone that joins the network is sent to the status page. The page is a single HTML file kept in LittleFS [6], [7] and sent by the built-in web server. Any unknown path returns a redirect to the page.
The page requests /api/status once per second. The reply is a JSON object holding the fault flag, phase, distance in kilometres, uptime, column and row names, the 4×4 matrix state, and the last ten events. The page draws a status banner, the matrix with conducting crossings highlighted, and the event list. The interface is read-only, so it cannot change the state of the line.
References
[1] IEEE Guide for Fault-Locating Techniques on Shielded Power Cable Systems, IEEE Std 1234, 2019.
[2] J. J. Grainger and W. D. Stevenson, Jr., Power System Analysis. New York, NY, USA: McGraw-Hill, 1994.
[3] eather0056, “Line-to-ground and line-to-line fault detection over IoT,” GitHub repository. [Online]. Available: https://github.com/eather0056/LINE-TO-GROUND-AND-LINE-TO-LINE-FAULT-DETECTION-OVER-IOT
[4] Espressif Systems, ESP32 Series Datasheet. Shanghai, China: Espressif Systems.
[5] Sharp Corporation, PC817 Series Optocoupler Datasheet. Osaka, Japan: Sharp Corp.
[6] Espressif Systems, “Arduino core for the ESP32.” GitHub repository. [Online]. Available: https://github.com/espressif/arduino-esp32
[7] littlefs-project, “littlefs: A little fail-safe filesystem designed for microcontrollers.” GitHub repository. [Online]. Available: https://github.com/littlefs-project/littlefs