Print an electronics enclosure: project box guide
What is a project box?
Sooner or later every homemade circuit needs a home: an electronics enclosure that holds the board securely, keeps the connectors reachable from outside and lets heat escape. Off-the-shelf plastic boxes are never the right size, and every opening has to be drilled and filed by hand. This generator builds the project box around your board instead: a base with standoffs, a lid that fits it exactly, and openings right where your connectors are.
You’ll find ready-made cases in the gallery, for example the Raspberry Pi 4 case, the Arduino Uno case, a control panel with pots and buttons or the two-color weather station box. Open one and adapt it to your project.
How the generator works
The generator runs entirely in your browser. Nothing is uploaded, and your design lives in the link: “Share” sends exactly this enclosure to someone else. The preview shows both parts the way they print – the base standing on its floor, the lid turned over next to it.
The design comes from YAPP_Box (“Yet Another Parametric Projectbox”) by Willem Aandewiel, one of the best-known OpenSCAD enclosure generators. We ported its box to TypeScript with the same parameter names and compared it with OpenSCAD: in 15 test cases – all six edge styles for base and lid plus boxes with standoffs – the outside dimensions match within a few hundredths of a millimeter. With square and chamfered edges the volume is identical too; with rounded edges it differs by less than 0.8 %, because we build the rounding in fine 0.25 mm steps.
YAPP’s principle: base and lid meet at a seam. Below it the base carries a ridge, the inner half of the wall, and the lid’s skirt slides over it from the outside. The lid sits flush, can’t shift, and still comes off again.
What you need
- Calipers to measure the board, its holes and the connectors.
- The board itself – clones tend to differ from the original by a millimeter.
- For a screw lid, M2.5 or M3 screws with matching heat-set inserts, or self-tapping screws.
- For wall tabs, two wood screws of 4 mm diameter.
The board presets under “Board” set the size, thickness, pin diameter and one standoff per mounting hole:
| Preset | Board (mm) | Holes |
|---|---|---|
| for Raspberry Pi 4 | 85 × 56 × 1.4 | 4, 58 × 49 mm grid |
| for Raspberry Pi Zero | 65 × 30 × 1.4 | 4, 58 × 23 mm grid |
| for Raspberry Pi Pico | 51 × 21 × 1.0 | 4, 47 × 11.4 mm grid |
| Arduino Uno format | 68.58 × 53.34 × 1.6 | 4 |
| Arduino Mega format | 101.6 × 53.34 × 1.6 | 6 |
| ESP32 DevKit (30 pins) | 51.5 × 28.3 × 1.6 | 4, 44.5 × 20.5 mm grid |
| Perfboard 5 × 7 to 8 × 12 cm | board size × 1.6 | 4, 2 mm from each edge |
The ESP32-CAM and Wemos D1 mini have no mounting holes; their presets only set the size.
Board and standoffs
The axes are YAPP’s: x runs from the back to the front (board length), y from left to right (board width). “Gap at the front”, “Gap at the back”, “Gap on the left” and “Gap on the right” set how much room stays between the board and the inner walls. “Base wall height” and “Lid wall height” define the space below and above the seam.
Each standoff sits at a position measured from the board corner, either alone or mirrored with “All four corners”. There are three types:
- Pin: the base gets a pin that goes through the board’s mounting hole; from the lid a pushdown with a socket comes down and holds the board in place.
- Socket: a hollow post for a screw or a pin, in the base and in the lid.
- Pin from the lid: the other way round – the pin grows down from the pushdown.
“Standoff height” (0–40 mm, default 1 mm) leaves room for solder joints under the board, “Pin diameter” and “Socket play” (default 0.4 mm) set the fit. Every standoff gets a small fillet at its foot, as in the original.
Openings for connectors, buttons and vents
Under “Openings” you add up to 40 cutouts on all six faces. Pick the face first, then tap a preset: USB-C, Micro-USB, USB-A, USB-B, Ethernet, HDMI, Micro HDMI, power jack, 3.5 mm audio jack, microSD, slide, rocker and toggle switches, 7 and 12 mm buttons, potentiometer, slide pot, LEDs, PG7 and PG9 cable glands, or a window for a 0.96″ display.
Each opening is a rectangle, a rounded rectangle, a circle or a fan. On the walls the position counts from the left side on the front and back, and from the back on the left and right; the height counts from the bottom of the box (“From the box”) or from the top of the board (“From the board”). The latter is handy: a USB port that sits on the board simply has a height of 1.5 mm. When an opening crosses the seam, the generator cuts it into both base and lid.
“Fill” turns an opening into a vent: honeycomb, holes, slots, bars or squares. The fan cutout adds an axial fan opening with a honeycomb grill and four screw holes, for example a 40 mm fan in the lid. “Hole clearance” (0–1 mm) makes every opening a little larger if your printer prints holes tight, and “Teardrop holes” gives round wall holes from 5 mm a pointed 45° roof.
Lid: ridge, snaps or screws
Three values control the fit: “Ridge height” (default 5 mm) is the overlap, “Ridge play” (default 0.2 mm) the gap between ridge and skirt, and “Ridge gap” (0.5 mm) makes sure the lid closes fully. Without anything else the lid holds by friction.
Snaps put a small round bump on the ridge and a matching slot in the lid’s skirt. As in the original they need a ridge at least 1.8 times the wall thickness; if yours is lower, the generator raises it and tells you. “Mirrored pair” adds a second snap at the other end of the same wall.
Screw posts are the sturdy option for lids you open often. Under “Screw posts” one tap adds four posts for M2.5 or M3 heat-set inserts or for M3 self-tapping screws. The screw head sits recessed from below in the base, and the screw runs through the post into the insert in the lid. Instead of a flat ceiling above the screw head the post gets a 45° slope, so it still prints without supports.
Edge styles, mounting tabs and label
“Edge style” offers YAPP’s six variants: all rounded, all square, all chamfered, only the corners rounded or chamfered, and rounded corners with chamfered top and bottom edges – the default, because chamfered edges come out cleanest on the bed. “Edge radius” sets the size; if it doesn’t fit the box, the generator reduces it. See the project box with chamfered edges.
Mounting tabs sit at the bottom of the base with a screw hole or a slot, so you can screw a sensor box to the wall – like the wall box with honeycomb lid.
The label on the lid is engraved into the top, up to 20 characters, and runs along the longer side. Leave the text size at 0 and it gets as large as the lid allows.
Colors and multi-material
Base, lid and label each have a color. Give the label its own color and it is inlaid flush into the lid and becomes a separate part in the “Multi-color 3MF (PrusaSlicer)” or “3MF (Bambu Studio / OrcaSlicer)” download – ready for an MMU3, XL or AMS. “STL per color (ZIP)” gives you the parts one by one.
A single extruder works too: the lid prints top face down, so the letters sit in its bottom layers. A color change (M600) at the “Engraving depth” (default 0.6 mm) colors exactly the letters. A lid in a different color is a separate part anyway.
Printing tips
- Orientation: as the generator lays the parts out – the base on its floor, the lid top face down.
- Supports: not needed. Your printer bridges the top edges of wall openings and snap slots; only very wide wall openings are worth softening with “Teardrop holes” or a lower height.
- Material: PLA for desk projects, PETG or ASA for warm power supplies and outdoor boxes.
- Print time and filament: in PrusaSlicer (Prusa MINI, 0.20 mm SPEED, Prusament PLA, 15 % infill) the Raspberry Pi 4 case takes 39 g of filament and 1 h 38 min for both parts, the small box for a Raspberry Pi Pico 9 g in 26 min.
- Heat-set inserts: press them straight into the posts with a soldering iron at about 220 °C; the project box with screw lid shows the layout.
- Fit: print a small box first. If the lid binds, raise “Ridge play” by 0.1 mm.
Origin and licenses
Base and lid with the ridge, the six edge styles, standoffs, screw posts, openings, snaps and mounting tabs are a port of YAPP_Box by Willem Aandewiel (MIT license); version 3 was built with Dave Rosenhauer and other contributors. The connector opening sizes, the ESP32 DevKit hole spacing, the perfboard rule, hole clearance and teardrop holes come from ESP32 Box Builder by Timothy Detournay (MIT), the control hole sizes from PCB Enclosure Generator by Haden Cain (MIT). The fan cutout and the square grill come from ParametricCase by Nirav Patel (BSD-2-Clause), the Mega format’s holes from openSCAD_functions by Paul van Dinther (Unlicense). Raspberry Pi, Arduino, ESP32 and Wemos are trademarks of their owners; we name them only to say what a preset fits. All license texts are on the licenses page.
Start in the generator, browse the examples, or build a matching rack tray and a fan grill for your homelab.
All parameters
The numeric settings of the generator with their default values and allowed ranges. Text, fonts, patterns and colors are set directly in the generator.
| Parameter | Default | Range | Meaning |
|---|---|---|---|
| Board | |||
| Board length | 120 mm | 5 – 170 mm | Size of the board from the back to the front (x). |
| Board width | 50 mm | 5 – 170 mm | Size of the board from left to right (y). |
| Board thickness | 1.6 mm | 0.4 – 20 mm | Usually 1.6 mm; the lid pushdowns stop on top of the board. |
| Standoffs | |||
| Standoff height | 1 mm | 0 – 40 mm | Gap between the floor and the underside of the board, room for solder joints. |
| Standoff diameter | 7 mm | 2 – 15 mm | Outside diameter of the standoffs and of the pushdowns in the lid. |
| Pin diameter | 2.4 mm | 0.8 – 6 mm | Pin that goes through the board’s mounting hole; a little smaller than the hole. |
| Socket play | 0.4 mm | 0 – 1.5 mm | Extra diameter of the sockets the pins slide into. |
| Box | |||
| Gap at the front | 1 mm | 0 – 60 mm | Space between the board and the front wall. |
| Gap at the back | 1 mm | 0 – 60 mm | Space between the board and the back wall. |
| Gap on the left | 1 mm | 0 – 60 mm | Space between the board and the left wall. |
| Gap on the right | 1 mm | 0 – 60 mm | Space between the board and the right wall. |
| Base wall height | 10 mm | 2 – 150 mm | Inside height of the base, from the floor to the seam where the lid sits. |
| Lid wall height | 10 mm | 1 – 150 mm | Inside height of the lid, from the seam to the underside of its top. |
| Shape & walls | |||
| Wall thickness | 2.8 mm | 1.2 – 6 mm | Thickness of the side walls; the ridge and the lid skirt are each about half of it. |
| Floor thickness | 1.6 mm | 0.8 – 6 mm | Thickness of the bottom of the base. |
| Lid thickness | 1.6 mm | 0.8 – 6 mm | Thickness of the top of the lid. |
| Edge radius | 3.8 mm | 0 – 20 mm | Radius of the rounded or size of the chamfered edges and corners. |
| Lid fit | |||
| Ridge height | 5 mm | 1 – 20 mm | How far base and lid overlap. Snaps need at least 1.8 × the wall thickness. |
| Ridge play | 0.2 mm | 0 – 1 mm | Gap between the ridge of the base and the skirt of the lid; more play makes the lid easier to fit. |
| Ridge gap | 0.5 mm | 0 – 2 mm | The lid skirt ends this much above the step of the ridge so the lid closes fully. |
| Printing | |||
| Hole clearance | 0 mm | 0 – 1 mm | Makes every opening this much larger, against tight fits from the printer. |
| Label | |||
| Text size | 0 mm | 0 – 40 mm | Height of the capital letters, 0 = as large as the lid allows. |
| Engraving depth | 0.6 mm | 0.2 – 1.5 mm | Depth of the letters in the lid. |
Frequently asked questions
Which boards have presets?
The Raspberry Pi 4, Zero and Pico, the Arduino Uno and Mega formats, a 30-pin ESP32 DevKit, the ESP32-CAM module, the Wemos D1 mini and perfboards from 5 × 7 to 8 × 12 cm. For any other board you enter length, width and holes yourself.
How does the lid hold?
The lid’s skirt fits over a ridge that runs around the base. Snaps click a small bump into slots in the skirt; alternatively you screw the lid down with screw posts and heat-set inserts.
How do I find where my connectors go?
Measure from the board corner with calipers and set the opening to “From the board”: the height then counts from the top of the board. The generator warns you when an opening runs into a corner, the floor edge or a standoff.
Do I need supports?
No. The base stands on its floor and the lid lies top face down. The top edges of wall openings and snap slots are short bridges that PrusaSlicer prints without supports, and round holes can get a 45° roof.
Can I print the case in two colors?
Yes. Base, lid and label get their own colors and their own extruders in the 3MF file. Because the label sits in the lid’s bottom layers, a single M600 color change works too.
What if the box does not fit my bed?
Base and lid normally lie side by side. When that gets too wide the generator warns you; set “Parts” to “Base only”, then to “Lid only”, and print them one after the other.
Origin & license
- YAPP_Box by Willem Aandewiel · MIT · code ported – base and lid with a ridge (YAPPgenerator_v3.scad: edge styles, standoffs, screw posts, cutouts, snap joins, mounting tabs) ported with the same parameter names; v3 with contributions by Dave Rosenhauer and others
- ESP32 Box Builder by Timothy Detournay · MIT · dimensions and shape adopted – connector opening sizes, ESP32 DevKit hole spacing, the perfboard hole rule, hole clearance and teardrop holes
- PCB Enclosure Generator by Haden Cain · MIT · dimensions and shape adopted – hole sizes of the lid controls (pots, push buttons, toggles, LEDs, slide pots, display windows)
- ParametricCase by Nirav Patel · BSD-2-Clause · helper code ported – fan cut-out with screw holes and the square grill (core/mech/fan-cutout.ts, vents.ts)
- openSCAD_functions by Paul van Dinther · Unlicense · dimensions and shape adopted – mounting holes of the Arduino Mega format preset