To safely control and monitor a 240 volt circuit from a low-voltage microcontroller, you must use strict galvanic isolation between the high-voltage AC mains and the DC logic side. A direct connection will destroy your board and poses a lethal shock hazard. The optimal topology for DIY automation, kiln control, or smart home sub-panels pairs a zero-crossing solid-state relay (SSR) for switching with an isolated Hall-effect current sensor for monitoring. This configuration provides 3,000V RMS isolation, eliminates mechanical contact bounce, and allows precise real-time power tracking without introducing shunt resistors into the mains path.
Topology and Node Mapping for an Isolated 240V Switch
In North America, a standard 240V split-phase supply utilizes two hot legs (L1 and L2) that are 180 degrees out of phase, yielding 240V RMS across them. For pure 240V loads (like baseboard heaters, water heaters, or workshop welders), a neutral wire is not required—only the two hots and an equipment grounding conductor (EGC). The control topology interrupts one of the hot legs using an SSR, while the current sensor clamps around or routes through the other hot leg.
Below is the specification sheet for the primary nodes in this design. We are using an ESP32-WROOM-32 for logic, a Fotek SSR-25DA for switching, and an Allegro ACS724 for current sensing.
| Node Label | Circuit Section | Nominal Voltage | Component / Wire Spec | Critical Parameter |
|---|---|---|---|---|
| L1 / L2 | Mains Supply | 240V AC RMS | 10 AWG THHN Copper | Ampacity: 30A (75°C column) |
| AC1 / AC2 | SSR Load Terminals | 24-380V AC | Fotek SSR-25DA | Max Load: 25A, V-drop: 1.6V |
| IN+ / IN- | SSR Control Input | 3-32V DC | ESP32 GPIO 25 | Drive Current: ~15mA at 5V |
| IP+ / IP- | Sensor Current Path | 240V AC (Pass-through) | ACS724LLCTR-30AB-T | Isolation: 3kV RMS, 1.2mΩ path |
| VCC / GND | Sensor Logic Power | 5.0V DC | Isolated DC-DC or USB 5V | Quiescent draw: 12mA |
| V_DIV | ADC Scaling Network | 0 - 3.3V DC | 10kΩ / 20kΩ Divider | Scales 4.5V max down to 3.0V |
Component Selection and Design Walkthrough
When designing a 240 volt circuit for microcontroller integration, component selection dictates both safety and signal integrity. Here is the step-by-step rationale for the chosen parts:
1. The Switch: Zero-Crossing SSR
We selected the Fotek SSR-25DA over a random-phase SSR or a mechanical contactor. The "DA" suffix indicates zero-crossing detection. When the ESP32 commands the relay ON, the internal triac waits until the AC sine wave crosses 0V before triggering. This drastically reduces inrush current and electromagnetic interference (EMI), which is critical when switching resistive heating elements or large transformers. Note that the SSR-25DA is rated for 25A, but NEC-style continuous load derating requires you to limit it to 80% of its rating (20A) unless mounted on a massive heatsink.
2. The Sensor: Hall-Effect vs. Shunt
The Allegro ACS724LLCTR-30AB-T measures current magnetically. The 240V AC flows through the IP+ and IP- pins, generating a magnetic field that the Hall sensor reads. This provides a 1.2mΩ series resistance (virtually zero voltage drop and no heat generation). Crucially, it offers 3,000V RMS galvanic isolation between the high-voltage IP pins and the low-voltage logic pins. For a detailed look at the internal architecture and isolation ratings, refer to the Allegro ACS724 Datasheet.
3. The Logic Interface: Voltage Scaling
A common bench mistake is wiring the ACS724 output directly to an ESP32. The ACS724 operates at 5V, meaning its quiescent output (0A) is 2.5V, and at +30A it outputs roughly 4.48V (using the 66mV/A sensitivity). The ESP32 ADC pins (like GPIO 34) are strictly limited to 3.3V. Feeding 4.48V into GPIO 34 will degrade or destroy the silicon. We must insert a voltage divider (20kΩ from sensor OUT to ESP32 GPIO, and 10kΩ from ESP32 GPIO to GND) to scale the 0-4.5V range down to a safe 0-3.0V range.
Circuit Behavior and Failure Extremes
Understanding how the topology reacts to variable conditions and extreme failures is what separates a working prototype from a reliable installation. The table below maps circuit behavior under dynamic changes, followed by an analysis of hard faults.
| Condition / Change | Physical Effect | Logic / Sensor Response |
|---|---|---|
| Load resistance drops (e.g., partial short) | Current spikes toward 30A+ | ACS724 V_DIV exceeds 2.8V; ESP32 software breaker trips SSR off in <10ms. |
| SSR Gate voltage drops to 1.5V | Internal LED dims below threshold | SSR turns OFF at the next zero-crossing. Load loses power safely. |
| Neutral wire disconnected (if 120V tap exists) | Split-phase voltage imbalance | 240V pure load is unaffected. 120V tap loads experience over/under-voltage. |
| Ambient temp inside enclosure hits 60°C | SSR internal thermal resistance rises | SSR may thermally latch or fail. Requires thermal fuse or software temp cutoff. |
What Breaks at the Extremes?
- SSR Output Shorted (Fails Dangerous): Triacs inside SSRs frequently fail in a short-circuit state if subjected to voltage spikes exceeding their dv/dt rating. If the SSR shorts, the 240V load remains permanently ON regardless of the ESP32's GPIO state. Mitigation: You must install a physical, manually operable disconnect switch or a standard thermal-magnetic breaker upstream of the SSR. Never rely on an SSR as a safety disconnect.
- Current Sensor Output Open (Fails Safe-ish): If the trace from the voltage divider to the ESP32 breaks, the ADC pin floats. The Espressif ESP32 ADC API will return erratic, noisy values. Mitigation: Software must implement a sliding window filter and an out-of-bounds check. If the raw ADC reading drops below 100 or spikes above 4000 (impossible with our scaled divider), the firmware must immediately command the SSR OFF and throw a fault flag.
Why This Topology Over Mechanical Contactors?
You might wonder why we don't just use a standard 240V mechanical contactor (like a Honeywell or White-Rodgers HVAC contactor) and a cheap shunt resistor for current sensing.
Furthermore, mechanical contactors suffer from contact welding. If a 240V motor stalls and draws 100A inrush, the contactor's physical metal contacts can melt and weld together, failing in the ON position. The SSR has no moving parts and cannot weld, though it can short as noted above. Finally, the zero-crossing SSR generates zero audible hum, whereas a 240V contactor will vibrate at 120Hz, creating an annoying mechanical buzz in residential environments.
Step-by-Step Breadboard Testing (Low-Voltage Proxy)
- Wire the Logic Side: Place the ESP32 and the ACS724 breakout board on your breadboard. Connect the ACS724 VCC to the ESP32's 5V (VIN) pin, and GND to GND.
- Build the Voltage Divider: Insert a 20kΩ resistor from the ACS724 OUT pin to ESP32 GPIO 34. Insert a 10kΩ resistor from GPIO 34 to GND. This scales the 5V sensor output to a safe 3.3V max.
- Wire the SSR Control: Connect ESP32 GPIO 25 to the SSR-25DA IN+ terminal. Connect the SSR IN- terminal to the breadboard GND. (The SSR-25DA has an internal current-limiting resistor for the input LED, so no external resistor is needed for 3.3V/5V logic).
- Apply the AC Proxy: Obtain a 12V AC wall-wart transformer (do not use a DC adapter; the SSR and sensor require AC to function correctly). Wire the 12V AC output in series with a 12V incandescent bulb (as a dummy load), passing one leg of the AC through the ACS724 IP+ and IP- terminals, and then through the SSR AC1 and AC2 terminals.
- Validate the Quiescent State: Power the ESP32. With the SSR OFF (GPIO 25 LOW), read the ADC on GPIO 34. It should read approximately 1800-1900 (representing the 2.5V quiescent offset, scaled down by the divider).
- Validate the Active State: Command GPIO 25 HIGH. The SSR should click on (or silently switch, depending on the zero-cross point), and the 12V bulb should illuminate. The ADC reading should now oscillate or settle at a higher value proportional to the bulb's current draw. Use your multimeter's AC clamp to verify the actual current, and confirm it matches the ACS724 math:
(ADC_Voltage - 1.65V) / (66mV/A * Divider_Ratio).
Mains Integration and Safety Verification
Once the low-voltage proxy test confirms your firmware logic, ADC scaling, and SSR switching, you can move to the physical 240 volt circuit panel integration. This requires abandoning the breadboard for proper termination.
Use 10 AWG THHN wire for the 240V load path, routed through liquid-tight conduit or appropriate cable assemblies. Terminate the L1 and L2 wires using properly sized ring terminals or ferrules, torqued to the manufacturer's specification (usually around 1.2 to 1.5 Nm for standard 25A SSR screw terminals). A loose terminal on a 240V 20A load will create a high-resistance joint, generating enough heat to melt the SSR housing and start a fire within minutes.
Before energizing the mains, perform a dead-short test with your multimeter in continuity mode. Place one probe on the equipment grounding busbar and the other on L1, then L2. You must read infinite resistance (OL). If you read continuity to ground, you have a short in your wiring or a failed SSR. Finally, ensure the metal enclosure housing the SSR and sensor is bonded to the equipment grounding conductor. Never leave the heatsink or mounting plate floating; capacitive coupling from the AC line can induce a hazardous shock voltage on ungrounded metal surfaces.






