Powering Maker Electronics from Mains AC Safely: Isolated Supplies, Fusing, and Enclosure Design
Sooner or later a maker project outgrows USB and wall-wart power and needs to run directly from mains AC — a shop tool controller, a permanently installed automation panel, or an enclosure that needs to switch real AC loads. This is also where the stakes change: our bench power supply guide and buck/boost converter guide both assume you're starting from a DC source, but getting DC from mains AC safely — inside a project enclosure you built yourself — is a different problem with real consequences if it's done wrong. This guide covers the safe, practical way to bring mains power into a maker project: using pre-certified isolated modules rather than building your own AC-DC conversion, and the fusing, wiring, and enclosure practices that keep it safe.
Don't Build Your Own AC-DC Converter
This is the one place in maker electronics where "just build it yourself" is the wrong default. A properly designed AC-DC supply needs galvanic isolation (a transformer or isolated switching topology that physically separates mains-referenced circuitry from your low-voltage output), correct creepage and clearance distances between mains and low-voltage traces, and safety agency certification (UL/CSA/CE) that a hobbyist board simply cannot self-certify. Buy a certified isolated AC-DC module instead — Mean Well's IRM and LRS series, HLK-PM01/PM12 modules, or a certified enclosed supply are inexpensive, compact, and have already solved the isolation and safety problems correctly. The money and time saved by not debugging a homemade mains supply is trivial compared to the risk of an isolation fault putting mains voltage on a circuit you're touching.
Bringing AC Into the Enclosure
ComponentPurpose IEC C14 Inlet (often fused)Standard, safe mains entry point with a removable cord — avoid hardwiring a captive cord where an IEC inlet will do Inline Fuse or Fused InletProtects against overcurrent and fault conditions on the mains side, sized to the supply's rated input current Isolated AC-DC ModuleConverts mains to your project's DC rail with certified galvanic isolation Mains-Rated Terminal Blocks or ConnectorsRated for the voltage and current involved — never repurpose low-voltage terminal blocks for mains wiring Strain Relief / Cable GlandsPrevents cord movement from stressing terminal connections at the inletUse an IEC C14 inlet with an integrated fuse holder where possible — it puts the fuse right at the point mains enters the box, protects the wiring inside the enclosure from the first inch, and lets you swap fuses without opening anything beyond the inlet cover. Size the fuse to the AC-DC module's rated input current with headroom for inrush (many switching supplies spec an inrush current well above steady-state draw — check the datasheet's inrush current rating and use a slow-blow fuse rated appropriately, not a fast-blow fuse that nuisance-trips on power-up).
Keeping Mains and Low-Voltage Physically Separated
Inside the enclosure, route mains wiring (inlet to fuse to AC-DC module input) on one side and keep it physically separated from the low-voltage DC output and any signal wiring — most fabricated enclosures and even 3D-printed project boxes benefit from a printed divider wall or a dedicated mains compartment, following the same enclosure-design thinking as our electronics enclosure design guide. Never route mains and low-voltage wiring in the same bundle or zip-tie them together — a chafed or pinched wire in a shared bundle is exactly the failure mode that puts mains voltage somewhere it doesn't belong. Use insulated ring or spade terminals on all mains connections rather than bare wire twisted into a terminal block, and torque terminal screws to the block manufacturer's spec — a loose mains connection arcs and generates heat, which is a fire risk independent of shock risk.
Grounding and Enclosure Material
If your enclosure is metal, the safety ground conductor from the IEC inlet must bond to the enclosure itself (a dedicated ground lug or star washer under a screw into bare metal, not just twisted around a bolt) so a fault that touches the case trips the fuse or breaker instead of energizing the enclosure. If your enclosure is 3D-printed or otherwise non-conductive, you don't have a chassis-ground path, so grounding integrity depends entirely on correctly wired connections at the inlet and supply — inspect those connections more carefully, since there's no metal case to serve as a backup safety path if something comes loose. Either way, the AC-DC module's DC output ground should never be tied to the AC safety ground on the low-voltage side of an isolated supply unless the datasheet specifically calls for it — bonding them defeats part of the isolation the module exists to provide.
Safety
Mains voltage (120V or 240V depending on region) can kill, and it doesn't announce itself the way a burn from a hot iron does — respect it accordingly. Always work on mains wiring with the enclosure unplugged, verify de-energized with a multimeter (see our multimeter guide) before touching any exposed terminal, and never work on live mains wiring alone in case something goes wrong. If your jurisdiction requires electrical work to be inspected or performed by a licensed electrician for anything beyond a plug-in appliance, follow that requirement — this guide covers safe practice for a self-contained, cord-connected project enclosure, not permanent building wiring, which is a different job requiring different qualifications. When in doubt about a specific wiring question, that doubt is the signal to stop and get it checked rather than guess.
Putting It Together
A well-built mains-powered enclosure looks almost boring: a fused IEC inlet, a certified isolated supply, mains wiring kept short, separated, and properly terminated, and everything downstream of the supply operating at a safe low DC voltage where the rest of your usual ESP32, Arduino, or relay-driven project logic takes over. That boring outcome is exactly the goal — the interesting, custom part of the project should be the control logic and the enclosure design, not the AC power stage, which is precisely why buying a certified module instead of building one is the right trade every time.
Related Guides
- Designing Enclosures for Electronics Projects: Materials, IP Ratings, Ventilation, and Cable Entry
- Parametric Box Generation for Laser Cutting with Boxes.py: Joints, Kerf, and Custom Layouts
- Build a Custom 3D-Printed Travel Case and Charging Dock for the ATS Mini V4
- Build a Passive Speaker System: Driver Selection, Crossover Design, and Enclosure Build