Build the layout around an insulated mounting plate: every PCB bolts to the plate on M3 nylon standoffs, with a 0.25 in [6 mm] creepage gap between the mains section and the logic section. Keep the mains hardware in a strip along the rear wall, and put the LCD, pots, switches and both fuses on the front panel. Mains rear, logic front, insulated plate between them is the standard topology for a hobby box that mixes line voltage with electronics. A 7.9 × 5.9 × 3.1 in [200 × 150 × 80 mm] enclosure carries this whole parts list with room to spare, and the sections below turn the topology into a build order you can drill to.
Which enclosure suits a mains Arduino project?
A moulded ABS or polycarbonate project box suits a dry indoor bench build, and a small 304 stainless wall-mount junction box takes over where the box gets splashed, hosed or left on a dusty wall; both work once an insulated plate goes inside.
The small stainless wall-mount junction boxes cover the nine smallest wall-mount sizes, each with a hinged gasketed door and a removable mounting panel, so you drill the panel and the box walls stay hole-free. They are rated NEMA 4X / IP66 by the manufacturer; not UL listed. Pick 316L instead of 304 for salt air, brine or chemical splash. For a bench project, any moulded box with a flat floor works, because the plate does the insulating either way. When you would rather have the cutouts arrive finished, custom enclosures take your drawing and machine every cutout from one piece, delivered in 10 business days from your approval of the drawing. Put the cable entries on the bottom rear wall and seal them with glands; every extra hole is a dust and water path.
What parts make the layout work?
One insulated plate, a bag of M3 nylon standoffs with matching screws, two panel-mount fuse holders, two cable glands and a mains terminal block cover every mounting and sealing job in this build.
- Insulated plate: 0.08 in [2 mm] FR4 or ABS sheet, cut 0.4 in [10 mm] inside the box floor all round, which gives 7.1 × 5.1 in [180 × 130 mm] in the worked example.
- Standoffs: M3 nylon, 0.39 in [10 mm] long, four per board. Read each module's drawing for its hole size; hobby modules are drawn with 3 mm [0.12 in] holes, so a 0.126 in [3.2 mm] clearance drill suits the screw.
- Screws: M3 × 0.24 in [6 mm] into each standoff, snug plus a quarter turn.
- Fuse holders: two panel-mount holders for 5 × 20 mm [0.20 × 0.79 in] cartridges, one per switched lead.
- Glands: two cable glands on the bottom rear wall, sized to each cable's outside diameter.
- Spacers: 0.2 in [5 mm] nylon posts under the plate, so solder tails and wire cross beneath without touching.
- A mains-rated terminal block for the incoming feed.
What is the standard topology inside the box?
Fix the insulated plate to the box floor, reserve the rear strip for the relay module, mains terminal and fuse supply side, keep every logic board forward of the creepage gap, and let mains wire run only along the rear and one side wall.
Three rules make the split hold. The user touches the front panel, so the panel carries nothing above the logic supply. The cable entries sit at the rear, so the mains hardware gathers there, close to where the wire lands. And the creepage gap stays a bare strip of plate, because a component body or a zip tie laid across it shortens the surface path to nothing. The same split, worked at weatherproof scale, is what the outdoor box carrying line voltage and low voltage together sets out, and the 120 VAC supply and relay in a small enclosure article handles the single-device version of the mounting problem. This article is the whole-board version.
How much distance separates the mains section from the logic section?
Hold 0.25 in [6 mm] of continuous surface and air distance between any mains pad, terminal or wire and any 5 V pad, terminal or board, and double it to 0.5 in [12 mm] where dust, oil or condensation settles.
IEC 60664-1 is the standard behind the figure: it sets creepage and clearance from the working voltage, the pollution degree and the laminate's tracking resistance, and its reinforced-insulation values for 230 V mains land at this distance on ordinary FR4. Creepage is the shortest path over a surface; clearance is the shortest path through air, and the gap needs both. Dust and moisture track across surfaces, so a damp or dusty spot earns double the distance. A slot milled through the plate under the gap buys surface path back without moving a single part. The relay module keeps its own contact pads clear of its coil pads, so the rule above governs section to section, across the plate. The mains-side optocoupler sensor sits wholly on the mains side of the plate, and only its logic output, isolated inside the package, crosses the gap.
What does a worked layout look like in a real box?
In a 7.9 × 5.9 × 3.1 in [200 × 150 × 80 mm] box, the plate is 7.1 × 5.1 in [180 × 130 mm], the mains strip takes 1.6 in [40 mm] of its depth, the creepage gap takes the next 0.25 in [6 mm], and 3.3 in [84 mm] remains for the logic boards.
The area check: 180 × 130 mm gives 23,400 mm² of plate, and the strip is 40 mm deep across the full 180 mm width, so 40 × 180 = 7,200 mm², about 31% of the plate, holds the relay module, the terminal block and the supply side of both fuse holders. The depth check runs 40 + 6 + 84 = 130 mm, and the 84 mm [3.3 in] logic zone swallows a Nano at 1.8 × 0.7 in [45 × 18 mm], the buck supply board and the sensor boards with harness room beside them. The fuse check: a 1 kW element at 220 V draws 1,000 / 220 = 4.5 A, so a 5 A cartridge rides above the running current and below the 10 A at 250 VAC contact rating the hobby relay's datasheet prints, leaving the contact at 45% of its rating. On the front panel, the common 16 × 2 character module draws 3.15 × 1.42 in [80 × 36 mm] overall, two potentiometers with 7 mm bushings take 5/16 in [8 mm] holes, and two switches with 1/4 in bushings take 0.26 in [6.5 mm] holes. Sizing the box from the plate first, as the control-panel layout sized from the mounting plate does for full panels, is what keeps this arithmetic honest.
How do you cut the front panel for the LCD, pots and switches?
Draw the whole panel first, with the LCD window, both pot holes, both switch holes and both fuse-holder cutouts on one drawing; drill a pilot in each corner, rough the window out, and file to the line, because one drawing beats four re-cuts.
Cut the LCD window to the view area on the module's drawing with about 0.02 in [0.5 mm] clearance a side, so the bezel laps the panel edge and hides the file marks. Pot and switch holes drill straight through at the 5/16 in and 0.26 in sizes from the worked example; deburr and clear the swarf before the plate goes back in. Both fuse holders panel-mount here, at finger reach, because fuses are the parts a user replaces. The cutouts, glands and windows guide carries the cutting and sealing method hole by hole, and the LCD mounting with cutouts and standoffs article covers bezels, spacers and window tolerances for the display itself.
What is the build order, start to finish?
Draw the plate, drill the box once, mount standoffs and plate, place the mains strip first, wire it, then fill the logic zone and close up.
- Draw the plate full size: mains strip 1.6 in [40 mm], creepage gap, logic zone; mark every standoff hole and every board footprint.
- Drill the plate: 0.126 in [3.2 mm] at each standoff point, plus the corner holes for the 0.2 in [5 mm] spacers.
- Cut the box once: two gland entries on the bottom rear wall; leave the rest of the box unholed.
- Bolt the plate to the floor on the spacers.
- Populate the mains strip first: relay module, terminal block and the supply side of both fuse holders, all on nylon standoffs.
- Wire the mains: feed to the terminal block, out through the contacts, each lead fused where it leaves the plate. Isolate the feed and prove it dead before the first terminal goes tight.
- Populate the logic zone: Nano, buck supply and sensor boards; brass standoffs are fine here.
- Route the harnesses: mains along the rear wall, logic along the front, any crossing square at 90 degrees.
- Mount the front panel: LCD, pots, switches, both fuse holders; then close the lid and run the checks below.
Which mistakes cost the build its safety?
Five faults break this layout: a through-bolt that leaves a board hanging off an outer wall, a brass standoff under a mains trace, mains wire running along the front panel, a relay contact loaded past its rating, and fuses buried where fingers cannot reach.
Each has a plain fix, and four checks catch them:
- Measure the creepage gap at its narrowest point with a rule; it reads at or above the design distance everywhere, screw heads included.
- With the feed isolated, meter from each mains terminal to the plate and to the box wall: an open reading, unless the wall is deliberately bonded to earth, which the grounding and bonding guide covers.
- Tug every mains lead and every standoff-mounted board; nothing shifts more than 0.04 in [1 mm].
- Bench-run the box at its real load for 30 minutes; the relay, the fuse holders and the buck supply stay only warm, and nothing rattles when you shake the case.
Mount every board to the plate, and the plate to the box, so undoing an outer screw leaves nothing dangling. Keep the mains hardware on nylon. Return the mains wire to the rear wall. Read the relay's contact rating off its datasheet before the load connects. Put the fuses where fingers reach. With the five faults out and the four checks green, the box is finished: mains pinned to the rear behind the gap, logic up front behind the panel, and every user-serviceable part on the panel.
Catalog dimensions to compare
Compare these catalog dimensions with your component layout. Open each enclosure for its rating, material and usable space, then check those specifications against your application.
| Enclosure | Material | Outside H x W x D / display | Rating |
|---|---|---|---|
| 12 × 10 × 6 in | 304 stainless | 12 x 10 x 6 in | Rated NEMA 4X / IP66 by the manufacturer; not UL listed |
| 20 × 16 × 8 in | 304 stainless | 20 x 16 x 8 in | Rated NEMA 4X / IP66 by the manufacturer; not UL listed |
| 24 × 20 × 8 in | 304 stainless | 24 x 20 x 8 in | Rated NEMA 4X / IP66 by the manufacturer; not UL listed |
Questions
Can brass standoffs go under the logic boards when nylon holds the mains side?
Yes, on the 5 V boards. A brass M3 standoff is stronger and re-usable, and logic pads around an isolated mounting hole tolerate it. On the relay module and anything at mains potential, fit nylon so a stray trace stays off the plate; nylon everywhere is the simple answer and it costs nothing extra.
What fuse suits a relay switching a 1 kW heater on mains?
A 5 A cartridge on each switched lead. The element draws 1,000 W / 220 V = 4.5 A, so 5 A rides above the running current without nuisance blows, and a hobby relay contact rated 10 A at 250 VAC stays far inside its rating. Fit the holder on the panel, and fuse where the lead leaves the plate.
Do the sensor wires cross the mains wiring safely?
Yes. Cross at 90 degrees, and keep parallel runs separated by at least the creepage gap; a sensor harness hugging the relay module's mains terminals is the arrangement that corrupts readings. Run the sensor harness along the front wall and the mains along the rear, so they meet only at the crossings.
Does the box need an earth connection with mains inside?
Bond the mains protective earth to an earth terminal on the plate, and when the box is metal, bond the box wall to that terminal too; the site's grounding and bonding guide explains the fault path the bond provides. A plastic box skips the bonding step, and every other rule of the layout stays the same.





