A test board with an ESP32-C3 module and a 3D-printable enclosure. Schematic, board, checks and enclosure are all generated by scripts. The enclosure's dimensions are not read off a drawing but from the board's 3D model, so it fits the connector and the LED.
The board is exported from KiCad with its components, copper and silkscreen; the enclosure and lid are the exact parts that go to the printer. The slider pulls the parts apart.
This is a test board from the FlatLock project, not the board the lock runs on today. It has not been manufactured or printed yet; what is verified and what is not is listed below.
Schematic, component placement, routing, the board in 3D and the enclosure step by step.
Full video
Short, under a minute
The board has two M2.5 mounting holes, so the enclosure holds it on two posts with screws. The cavity also fits the module's antenna, which overhangs the top edge of the board. Every dimension is derived from the board.
Outline and component bodies from the board's 3D model, holes from the board file. The module's antenna overhangs the top edge by 5.4 mm.
1.6 mm with rounded corners. 0.4 mm clearance around the board and antenna on every side.
Height is set by the tallest part: the J1 header stands 8.5 mm above the board, plus 0.5 mm margin.
Two 5 mm posts grown from the base, with a 2.2 mm pilot hole. J1 pins stick out 1.5 mm below the board, so the posts hold it 2.5 mm above the base.
A 3 mm lip drops into the box with 0.2 mm clearance, to be tuned on the first print.
Two M2.5 x 6 mm self-tapping screws through the board's holes into the posts. A check makes sure no screw head hits a component and the lid's lip does not hit a screw.
An opening right above J1 with 0.6 mm clearance for the cable connector, a 2.6 mm window above LED D1. Positions taken from the board.
Three slots in each long wall next to the regulator, which dissipates 0.58 W at peak.
On the previous board, component positions were copied into the enclosure model by hand and ended up 10 mm off. Here no number is copied. When the board changes, the enclosure is recomputed with one command.
Placed according to the schematic's netlist.
kicad-cli exports it including the package models.
A script reads the board outline and a box around each component, and the holes from the board file.
OpenSCAD derives the dimensions and stops on anything that would collide.
Print-ready parts, the step images and the 3D model above.
Why from the 3D model and not the board drawing: the package outline in the drawing is an assembly courtyard with an allowance, not the real body, and it has no height at all. The opening in the lid and the gap above the board need the actual body.
Drawn as a document, not as a list of connections: power and functional blocks are drawn as wires; labels remain only where a wire would have to go around the whole module. Until 24 Oct 2026 a script wrote it and compared the netlist with the expected nets. Since then the KiCad file is the source and every change is made by a recorded script.
| Pin | Signal |
|---|---|
| 1 | 5 V |
| 2 | GND |
| 3 | TXD (module output) |
| 4 | RXD (module input) |
| 5 | EN (reset) |
| 6 | IO9 (boot) |
One cable both powers and programs the board. The LED is on GPIO10 because GPIO2, 8 and 9 decide the boot mode at startup and an LED to ground could pull them low. That is also why GPIO2 and GPIO8 have 10 kΩ pull-ups per the module's reference design, and TXD runs through R5 499 Ω right at the pin. RXD has R6 1 kΩ in case a programmer drives it at 5 V. 5 V, 3.3 V and ground can be measured at test points TP1 to TP3.
Two layers, 23.75 x 34.8 mm. The size follows the content, not a guess: stitching and the 3.3 V bus on the left, the TXD corridor on the right, the mounting holes under the header at the bottom. The board ends exactly at the base of the module's antenna and the antenna overhangs by 5.4 mm, so there is no copper next to it, as Espressif recommends for the module. Ground is a copper pour on both sides, stitched together by 32 vias around the edge with a largest gap of 6.7 mm. C1, C2 and C4 connect to ground through thermal spokes so they can be soldered, no silkscreen lies on a via, and header pin 1 is labelled “+5V”. There is silkscreen on the top only, a second one costs extra at the fab: the header pins are labelled in copper on the bottom and the board name is an opening in the solder mask over ground.
These numbers are not estimates. A script computes them directly from the finished board, so they cannot drift from the design.
The peak is the module transmitting over Wi-Fi. The module figures are commonly quoted values for now, not from the datasheet.
Per IPC-2221 (18 µm copper), 0.134 mm is enough for 344 mA. Half a millimetre is therefore not about heating but about voltage drop and lower inductance.
| State | Loss | Die, 25 °C ambient |
|---|---|---|
| idle, 109 mA, 1 cm² copper | 0,19 W | 36 °C |
| peak, 344 mA, 1 cm² copper | 0,58 W | 61 °C |
| peak, no copper at the tab | 0,58 W | 95 °C |
The junction limit is 125 °C, so copper at the tab is a necessity. The estimate assumes 1 cm²; the board has 62 mm² around the tab, so the die will run hotter. How much will be measured on a manufactured board.
| Where | Loop | Inductance | |
|---|---|---|---|
| C3 100n | module supply | 3,8 mm | 1,5 nH |
| C5 10u | module supply | 11,2 mm | 4,5 nH |
| C4 1u | module EN | 8,3 mm | 3,3 nH |
| C2 22u | regulator output, tantalum | 6,0 mm | 2,4 nH |
| C1 10u | regulator input | 4,8 mm | 1,9 nH |
What matters is the area of the current loop, not the distance from the pin. Each capacitor therefore has a ground via in the same copper island at most 1.1 mm from its pad, and the regulator's ground pin has two vias 0.6 mm from its pad.
Manufacturing is designed for the fab's cheapest standard spec: 1.5 mm board, construction class 5, narrowest trace 0.30 mm, clearance 0.25 mm, smallest drill 0.40 mm. No surcharges.
Send me your KiCad board. The enclosure is computed from its 3D model and you get STL files for printing plus images for your documentation. Or we start from the schematic.
Send an emailDavid Petrov · davidpetrov@email.cz