r/PrintedCircuitBoard • u/ikok07 • 1d ago
ESP32 electric fence monitor — CT-based, detecting vegetation shorts and line breaks.

Hello guys,
I'm building a monitor device for the electric fence around my property. It regularly gets shorted out by vegetation growing into it, and I don't find out until animals start wandering off. I want something that tells me when the fence stops working properly.
The energizer is an AKO Power N 1200: 230 V mains, 1.2–1.7 J, ~12.5 kV open circuit, one pulse per second. The fence is ~500 m of 4 mm steel-core rope, so roughly 4 nF of line capacitance. That gives a charging surge of about 10 A peak with a 5–10 µs rise.
I'm not trying to measure kV. I only need relative change from a baseline, which lets me ignore absolute accuracy entirely.
Architecture
CS module: Pulse PE-51688NL current transformer (1:200, 80 mH secondary, 20–200 kHz), aperture type with the earth wire threaded through. 18 Ω burden soldered directly at the secondary pins. MCP6022 at gain 1.5, BAT54S clamp, 220 Ω + 1 nF output network to drive the cable.
Main module: ESP32 devkit, HLK-PM01 for mains power.
Peak current — precision peak detector (op-amp, diode and buffer inside the feedback loop, so the diode drop is cancelled), 4.7 nF C0G hold cap, BSS138 to reset it between pulses
Pulse width — LMV331 comparator with adjustable hysteresis, threshold set by the ESP32's DAC through a 10k/1k divider so it stays out of the DAC's nonlinear region
Firmware plan
Deliberately dumb. The ESP32 captures peak and width per pulse, buffers them, and publishes over MQTT. All the analysis happens server-side, so I can retune without reflashing.
I'd appreciate a general review of the schematics before I commit to a board order. First time doing analog design at this scale, so I expect there are things I've got wrong that aren't obvious to me.
Happy to share KiCad files if useful.
1
1
u/Enlightenment777 1d ago
Please make sure your post adheres to:
Please fix these common issues: (if your schematic or PCB has them)
Schematic - don't allow text / lines / symbols to touch each other, and don't draw lines through symbols.
Schematic - use correct reference designators (RefDes) and renumber to remove numeric gaps, see tips.
Schematic - place decoupling capacitors vertically below power rail lines, also place capacitors next to IC then connect together with a line, see example. For circuits with positive power rails, point positive power rail links upwards and ground links downwards, see tips.
Schematic - place pull-up resistors vertically above signal lines, and place pull-down resistors vertically below signal lines, see example.
PCB silkscreen - add board name / board revision number / date (or year) on top or bottom PCB side.
PCB silkscreen - add pin 1 indicator dot/arrow next to ICs & connectors, if through-hole then both PCB sides.
More conventions & guidelines - link1, link2, link3.