Parametric PCB Enclosure & Integrated Battery Bay
A professional-grade, parametric 3D-printable enclosure designed in OpenSCAD. The project integrates:
- a rectangular PCB compartment
- a circular twist-lock (bayonet) battery holder
Optimized for CR2032 (and similar coin cells).
The source code is structured according to the Single Responsibility Principle (SRP), with each module handling a single concern.
-
ArcSector Pure geometric utility for polar-based locking mechanisms.
-
TabCutout Independent module for snap-fit lid retention.
-
MaleBatteryCap / FemaleBatteryBay Decoupled components implementing the bayonet locking system.
-
KeychainModule (optional) Structural add-on for keychain or lanyard attachment.
| Parameter | Default | Description |
|---|---|---|
batt_dia |
21 mm | Internal diameter for the battery cell |
square_side_x |
35 mm | PCB compartment width |
square_side_y |
34 mm | PCB compartment depth |
wall |
3.0 mm | Structural wall thickness (FDM / SLA) |
clearance |
0.3 mm | Mechanical tolerance for interlocking parts |
$fn |
100 | Resolution for cylindrical surfaces |
-
Bayonet Lock 45ยฐ rotation locking system with a 90ยฐ guide channel.
-
Cable Routing Integrated 55ยฐ angled slots for wiring cables from batteries
-
Fastening System Built-in M3 standoffs for PCB mounting.
- OpenSCAD (latest version recommended for faster rendering).
- 3D printer calibrated for 0.3 mm tolerances.
To adapt the enclosure for a different PCB or battery size, modify the parameters in the header section of the OpenSCAD file.
square_side_x = 40; // New PCB width
square_side_y = 40; // New PCB depth
batt_h = 3.2; // CR2032 heightThe script automatically generates three separate parts, laid out side-by-side for convenient printing:
-
Main Chassis PCB tray + female bayonet + optional keychain module
-
Top Lid Snap-fit protective cover
-
Battery Cap Male twist-lock bayonet cap
- Designed for parametric reuse across multiple PCB revisions.
- Compatible with both FDM and SLA printing workflows.
- Clearances tuned for consumer-grade printers; adjust if using resin or industrial systems.
- I printed it using a Bambulab A1 mini with PETG filament but I think any filament would fit right.