← 3D modelling

Board and enclosure FlatLock_00

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.

board 23.75 x 34.8 mm enclosure 28.55 x 44.93 x 16.24 mm DRC 0 errors KiCad + OpenSCAD

3D model: the board in its enclosure

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.

The enclosure step by step

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.

Krok 1: deska se součástkami jako obalové kvádry

1Board from KiCad

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.

Krok 2: dno krabičky

2Base

1.6 mm with rounded corners. 0.4 mm clearance around the board and antenna on every side.

Krok 3: stěny krabičky

3Walls

Height is set by the tallest part: the J1 header stands 8.5 mm above the board, plus 0.5 mm margin.

Krok 4: deska na dvou sloupcích pod montážními otvory

4Posts under the holes

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.

Krok 5: víko s lemem

5Lid with a lip

A 3 mm lip drops into the box with 0.2 mm clearance, to be tuned on the first print.

Krok 6: dva šrouby M2,5 přes desku do sloupků

6Screws

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.

Krok 7: průchod pro kabel nad konektorem a okénko nad LED

7Cable and LED

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.

Krok 8: větrací štěrbiny v bočních stěnách

8Vents

Three slots in each long wall next to the regulator, which dissipates 0.58 W at peak.

Oba díly na podložce tiskárny: krabička dnem dolů a víko obrácené vedle ní
Both parts print without supports: the box base-down, the lid upside down next to it. Outer size 28.55 x 44.93 x 16.24 mm.

Where the enclosure gets its dimensions

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.

  1. Board in KiCad

    Placed according to the schematic's netlist.

  2. Board 3D model

    kicad-cli exports it including the package models.

  3. Component bodies

    A script reads the board outline and a box around each component, and the holes from the board file.

  4. Enclosure model

    OpenSCAD derives the dimensions and stops on anything that would collide.

  5. STL and this page

    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.

Schematic

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.

Schéma FlatLock_00: napájení 5 V přes AMS1117-3.3 s tantalovým C2, modul ESP32-C3-MINI-1 s blokováním C3 a C5, RC článek na EN, pull-upy na GPIO2 a GPIO8, R5 v TXD, R6 v RXD, LED na GPIO10, měřicí body a programovací konektor J1
Click to open full size. ERC: 0 errors, 0 warnings.

Connector J1

PinSignal
15 V
2GND
3TXD (module output)
4RXD (module input)
5EN (reset)
6IO9 (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.

The board

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.

Osazená deska shora: modul ESP32-C3-MINI-1, stabilizátor AMS1117, tantalový C2, kondenzátory, LED, měřicí body, hřeben J1 a dva montážní otvory
Assembled board, top
Deska zespodu se zemní plochou, popisem pinů J1 a označením FlatLock_00
Bottom: ground pour, J1 pin labels and board ID
Měď na horní vrstvě: spoje, plošky, zemní plocha a prokovy po obvodu
Top copper
Měď na spodní vrstvě: zemní plocha, spoje EN a TXD, popis pinů v mědi a jméno desky v masce
Bottom copper: solid ground, only EN and TXD run underneath

What was calculated

These numbers are not estimates. A script computes them directly from the finished board, so they cannot drift from the design.

Current budget

109 mA idle · 344 mA peak

The peak is the module transmitting over Wi-Fi. The module figures are commonly quoted values for now, not from the datasheet.

Power trace width

0.5 mm where 0.134 mm would do

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.

AMS1117-3.3 regulator

StateLossDie, 25 °C ambient
idle, 109 mA, 1 cm² copper0,19 W36 °C
peak, 344 mA, 1 cm² copper0,58 W61 °C
peak, no copper at the tab0,58 W95 °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.

Decoupling capacitors

WhereLoopInductance
C3 100nmodule supply3,8 mm1,5 nH
C5 10umodule supply11,2 mm4,5 nH
C4 1umodule EN8,3 mm3,3 nH
C2 22uregulator output, tantalum6,0 mm2,4 nH
C1 10uregulator input4,8 mm1,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.

What is verified and what is not

Verified

  • Schematic: ERC 0 errors and 0 warnings, drawing check with no findings.
  • Board: DRC against the fab's rules, 0 violations and 0 unconnected pads, 0 differences from the schematic.
  • Electrical checks by script: currents, trace widths, regulator heating, decoupling, antenna fully off the board, pull-ups and R5, a ground via at every ground pad, no unconnected ground island.
  • Enclosure: checks in the model that no post hits a pin, no screw head hits a component and the lid's lip does not hit a screw.

Not verified yet

  • The board has not been manufactured and the enclosure has not been printed.
  • The circuit follows Espressif's design guidelines and the AMS1117 datasheet. The module's current draw in the budget, however, is a commonly quoted figure, not checked against the datasheet.
  • The regulator's copper area is 62 mm², still less than the 1 cm² the heating estimate assumes. To be measured on a board.
  • Espressif recommends 15 mm of free space around the antenna; the enclosure leaves only 0.4 mm clearance and the wall. Wi-Fi range inside the enclosure will be checked on a board.
  • The M2.5 self-tapping screw into plastic with a 2.2 mm pilot hole has not been tried yet.
  • The lid opening assumes a 1x6 Dupont connector; not tried on an actual cable.
  • The 0.2 mm lip clearance will be tuned on the first print.

An enclosure for your board?

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 email

David Petrov · davidpetrov@email.cz