If your ESP32, Arduino, or Raspberry Pi project switches 120V or 240V AC in a damp location—such as an automated greenhouse, an aquarium heater controller, or an outdoor pond pump—you must use a GFCI ground fault circuit interrupter rated for your load, wired on the LINE side of your project, with a dedicated equipment ground. Do not rely on standard breakers or software-based fault detection to protect human life. For 90% of maker mains-projects in damp environments, the concrete pick is a Leviton GFSW2-W 20A GFCI receptacle, with your project's AC input wired directly to its LOAD terminals.
The Lethal Hazard: Why Your ESP32 Mains Project Needs GFCI Protection
Before wiring a single terminal, you must understand the specific hazard this practice prevents. A standard 15A or 20A thermal-magnetic breaker is designed to protect wiring from melting due to overloads or dead shorts. It will not trip until current exceeds 15,000 milliamps (15A). However, human ventricular fibrillation can be triggered by as little as 50mA across the chest, and the threshold for involuntary muscle contraction (where you cannot let go of the energized object) is around 10mA to 15mA.
A GFCI ground fault circuit interrupter monitors the current balance between the hot and neutral conductors. If it detects an imbalance as small as 4mA to 6mA—indicating current is leaking to ground, potentially through a person—it trips the circuit in under 25 milliseconds. According to OSHA electrical safety guidelines, GFCIs are the primary defense against electrocution in environments where water and electricity intersect.
Ground vs. Neutral vs. Bond: Where Makers Get It Wrong
Embedded developers are used to DC circuits where 'ground' (GND) is the universal 0V return path for all current. In AC mains wiring, conflating these concepts is deadly. You must clearly distinguish between three distinct conductors:
- Neutral (Grounded Conductor): The normal, intended return path for AC current. It carries the exact same current as the hot wire during normal operation. (US color: White or Gray).
- Ground (Equipment Grounding Conductor / EGC): A safety shield that carries zero current during normal operation. It only carries current during a fault to provide a low-impedance path back to the panel, facilitating a breaker trip and keeping the chassis near 0V. (US color: Bare copper or Green).
- Bond: The physical, intentional connection between the Neutral and the Ground. In a standard residential system, this bond occurs only at the main service disconnect panel.
The Fatal Maker Mistake: Some builders, finding that their project enclosure lacks a ground wire, will 'bootleg' a ground by tying the neutral wire to the ground screw on their project box. This creates a parallel neutral path. If the neutral wire breaks upstream, your project chassis instantly becomes energized at 120V. Furthermore, tying neutral and ground together downstream of a GFCI ground fault circuit interrupter will cause the GFCI to trip immediately or, worse, blind its sensing coil to actual human shocks.
In complex setups like large aquariums, you should also consider equipotential bonding (connecting all exposed conductive parts, like tank hoods and light fixtures, to a common ground so no voltage difference can exist between them). This ensures that even if a fault occurs, touching two metal parts simultaneously won't result in a shock.
Decision Tree: Which GFCI Setup to Use
Use this decision matrix to determine the correct protection level for your embedded project. Do not guess; match your project's environment to the required hardware.
| Project Environment | Mains Connection Type | Required Protection | Concrete Hardware Pick |
|---|---|---|---|
| Indoor Dry (Desk/Office) | Standard 120V Plug | Standard Breaker (GFCI optional but good practice) | Leviton 5262-W (Standard 15A Receptacle) |
| Damp/Outdoor (Greenhouse, Pond, Aquarium) | Plug-in or Hardwired Inline | GFCI Receptacle (Project on LOAD side) | Leviton GFSW2-W (20A GFCI) |
| Whole Circuit / Hardwired Roof or Floor | Panel-fed Dedicated Line | GFCI Circuit Breaker | Square D HOM120GFIC (20A GFCI Breaker) |
The Default Pick: For the vast majority of IoT maker projects (ESP32 plant waterers, Raspberry Pi terrarium heaters), you will be building an inline control module that plugs into a wall outlet. Replace that wall outlet with the Leviton GFSW2-W. It provides 20A capacity (handling the startup surge of inductive loads like water pumps) and features a tamper-resistant design that prevents accidental contact with the line terminals.
Step-by-Step: Wiring a Smart Relay Behind a GFCI Receptacle
When wiring your ESP32 smart relay module (such as a custom PCB using an ESP32-WROOM-32 and a solid-state relay like the Fotek SSR-25DA), the project must be wired to the LOAD terminals of the GFCI. This ensures the GFCI monitors the current going to your project.
- De-energize and Verify Dead: Turn off the breaker at the main panel. Use a non-contact voltage tester (like the Klein NCVT-1) and then verify with a multimeter (like the Fluke 117) set to AC voltage. Measure Hot-to-Neutral, Hot-to-Ground, and Neutral-to-Ground. All must read 0V.
- Identify Line vs. Load: In the wall box, the wires bringing power from the panel are the LINE. The wires continuing to other outlets are the LOAD. If your project is the only thing on the circuit, you will only have LINE wires.
- Wire the GFCI LINE Terminals: Connect the incoming Hot (Black) to the brass LINE screw, and the incoming Neutral (White) to the silver LINE screw. Connect the bare/green Ground to the green grounding screw.
- Wire Your ESP32 Project to the LOAD Terminals: Run a 3-conductor cable (Hot, Neutral, Ground) from the GFCI's brass and silver LOAD screws to your project enclosure. Do not skip the ground wire.
- Terminate Inside the Project Box: Use Wago 221 lever nuts to pigtail the wires inside your enclosure. Connect the incoming Ground directly to your project's metal chassis or the ground pin of your AC-DC power supply (like a Mean Well IRM-03-5). Never use the ground wire as a DC logic ground for your ESP32.
While the GFCI stops the shock hazard, the upstream breaker handles dead shorts. The breaker's let-through current (the maximum thermal and magnetic energy permitted to pass through the device before its contacts fully open and extinguish the arc) is what protects your project's internal wiring from melting during a catastrophic short circuit. Ensure your internal project wiring is sized correctly (minimum 18 AWG for 120V AC) to withstand this let-through energy.
Verification: Testing the GFCI and When to Call a Pro
Once wired, you must verify the protection exists and works before connecting your ESP32 or applying power to the load.
- Restore power at the main panel. The GFCI should have power, and your ESP32 should boot.
- Plug a dedicated GFCI tester (such as the Klein Tools RT210 or Gardner Bender GFI-3501) into a receptacle on the LOAD side of your setup, or wire a temporary test receptacle to your project's AC output.
- Press the black 'Test' button on the tester. The GFCI receptacle should immediately trip with an audible click, cutting power to your ESP32.
- Press the 'Reset' button on the GFCI receptacle. Power should restore.
When to Call a Licensed Electrician: If you open the existing wall box and find only two wires (a black hot and a white neutral) with no bare or green ground wire, stop. You are working with an older, ungrounded circuit. While the NFPA National Electrical Code allows replacing an ungrounded receptacle with a GFCI ground fault circuit interrupter (marked 'No Equipment Ground'), this is intended for simple appliance use. For a maker project involving water, relays, and exposed electronics, relying on a GFCI without a true equipment ground is insufficient for equipotential safety. You must hire a licensed electrician to pull a new feeder cable with an EGC, or run a new dedicated circuit from the panel.






