Printing an enclosure
Design a 3D-printed enclosure for an ESP32-C5 sensor from the official drawings: parametric source, print tolerances, venting for the sensor, a 15 mm antenna keep-out and what filament does near the antenna.
You will learn
- Take enclosure dimensions from the official board and module drawings, with their tolerances
- Write parametric OpenSCAD so a clearance or a board change is one edit
- Keep 15 mm clear around the PCB antenna and choose material for the antenna zone
- Place and vent a humidity or temperature sensor away from the board's heat
A sensor on a bare devkit works on the bench and fails in the real world: dust on the board, a sensor reading the heat of its own regulator, a radio link that drops when you close the lid. This lesson covers the design rules for a 3D-printed enclosure around an ESP32-C5-DevKitC-1 and a small sensor. It does not hand you a finished model. That lives on its own page, /build/c5-devkit-vented-enclosure/, with the source, print files and its print status. Here you learn why that design looks the way it does, so you can change it or draw your own.
Start from the official drawing
Every dimension comes from the maker’s drawing, never from a photo or a marketplace listing. Espressif publishes a dimension drawing for the ESP32-C5-DevKitC-1 v1.2 (PDF and DXF, dated 9 May 2025). It gives:
| Feature | Value |
|---|---|
| PCB outline | 25.40 × 53.60 mm |
| Module antenna beyond the PCB edge | 6.50 mm |
| Header rows, centre to centre | 22.86 mm |
| Header pitch | 2.54 mm |
| Module width | 18.00 mm |
The module on the board, the ESP32-C5-WROOM-1, has its own drawing in its datasheet (v1.3, Section 10.1): 18 ± 0.2 mm wide, 27.5 ± 0.2 mm long and 3.3 ± 0.15 mm tall, with a 6.5 mm antenna area at one end. Those ± values matter. A pocket drawn at exactly the nominal size will not fit a module at the top of its tolerance.
Some numbers you need are not in any drawing, such as the PCB thickness or the height of the USB-C plug’s overmould. Measure them with callipers on your board and mark them as assumptions in the source, so the next person knows which numbers to trust.
Parametric source
Write the enclosure as code. OpenSCAD is a good fit: the model is a text file that diffs cleanly in git, and our CI can render it and check its size. Put every dimension in a named variable at the top, with its source next to it:
// snippet
/* [Board: ESP32-C5-DevKitC-1 v1.2, Espressif dimension drawing v1.2] */
pcb_w = 25.40; // PCB width
pcb_l = 53.60; // PCB length
ant_overhang = 6.50; // module antenna beyond the PCB edge
mod_w = 18.00; // module width (datasheet: 18 +/- 0.2)
/* [Rules] */
ant_clear = 15; // Espressif: 15 mm around the PCB antenna inside the housing
fit = 0.25; // printer clearance per side: a starting value, measure yours
wall = 2.0;
The /* [Name] */ block comments make OpenSCAD’s Customizer show the variables on named tabs, so a reader can change a value without reading the geometry. The Customizer only picks up assignments that come before the first { in the file, so keep parameters at the top. Everything below the parameters is derived from them. When the next board revision moves a connector, you change one number.
Tolerances
A printer does not reproduce the size you drew exactly. The error depends on your printer, nozzle, material and slicer settings, so no single number is right for everyone. The design therefore carries one clearance parameter, fit, added on every side of anything that must slide together:
// snippet
// Pocket for the board: nominal size plus clearance on each side.
pocket_w = pcb_w + 2 * fit;
pocket_l = pcb_l + 2 * fit;
// A test coupon: one slot per candidate clearance, labelled by position.
for (i = [0 : 4])
translate([i * 8, 0, 0])
difference() {
cube([6, 10, 4]);
translate([1, -1, 1]) cube([2 + 0.1 * i, 12, 4]); // 2.0 to 2.4 mm slots
}
Print a small coupon like this before the full enclosure, test it with the real part, and set fit to the smallest clearance that slides without force. Add the part’s own tolerance on top: the module’s ± 0.2 mm is not something your printer can absorb for you. Our print tolerances and enclosure rules reference page collects the other rules of thumb in one place.
Keep the antenna clear
The DevKitC-1 uses the module’s PCB antenna, which overhangs the board edge by 6.50 mm. Espressif’s ESP32-C5 Hardware Design Guidelines (Section 1.4.7) say to place the antenna at or beyond the board edge, to keep it clear inside the end product’s housing, and recommend a clearance of at least 15 mm in all directions. They also say to test the final product’s throughput and range.
In practice that makes the box longer and wider than the board, and it puts empty space above and below the antenna too. Keep screws, threaded inserts, the battery, cables and any metal out of that zone. Let the code enforce it, so a later edit cannot quietly break the rule:
// snippet
inner_l = pcb_l + ant_overhang + ant_clear + 2 * fit; // USB end to far wall
inner_w = max(pcb_w, mod_w + 2 * ant_clear) + 2 * fit; // 15 mm each side of the antenna
assert(inner_l - pcb_l - ant_overhang >= ant_clear, "antenna end wall is inside the keep-out");
assert((inner_w - mod_w) / 2 >= ant_clear, "side walls are inside the keep-out");
The Build page explains how its design applies the 15 mm figure and which values it takes from the drawings.
Material near the antenna
Plastic is not invisible to a radio. Two properties describe how it interacts with the field: its relative permittivity, which can shift an antenna’s tuning, and its loss tangent, a measure of how much energy it absorbs. Castro and co-authors (2026, open access) measured printed samples of seven filaments with a resonant cavity at 3.5 GHz:
| Filament | Fill | Relative permittivity | Loss tangent |
|---|---|---|---|
| ABS | 100 % | 2.55 | 0.0067 |
| PETG | 100 % | 2.69 | 0.0070 |
| PLA | 100 % | 2.89 | 0.0110 |
| CR-carbon | 100 % | 3.54 | 0.0200 |
| ABS | 25 % | 1.65 | 0.0021 |
| PETG | 25 % | 1.71 | 0.0031 |
| PLA | 25 % | 1.60 | 0.0042 |
| CR-carbon | 25 % | 1.83 | 0.0095 |
Read this with care. The measurements are at 3.5 GHz, between the ESP32-C5’s two Wi-Fi bands, on one sample per material and fill, from one set of spools. The paper does not describe the composition of the filament it calls CR-carbon. Two patterns are still useful. The filament with “carbon” in its name had the highest permittivity and loss at full density, and the authors rate it, with PETG, Nylon and Tritan, as mostly less suitable for RF parts. And less plastic means less effect: at 25 % fill every material’s permittivity and loss fell well below its full-density value.
For the enclosure, that gives simple rules. Use a plain, unfilled filament for any wall within the keep-out zone. Keep carbon-filled and metal-filled filaments out of it: the one carbon-named filament in the paper had the highest loss, and we have not measured metal-filled ones. Keep walls near the antenna thin and away from it, and do not add solid features such as bosses or ribs inside the zone. How much a real enclosure costs in signal is a question for a measurement. Our method for it is /lab/methods/rf-loss-through-enclosures/.
Venting the sensor
A temperature or humidity sensor measures the air around it, and inside a closed box that air is warmed by the board. The ESP32-C5 alone draws 87 mA while receiving on 2.4 GHz (datasheet v1.5, Table 5-7), and the regulator and LEDs add their own heat. Sensirion’s design guide for its humidity and temperature sensors (Version 2, March 2024) gives four rules that carry over to any sensor of this kind:
- Keep the air volume around the sensor small, so the outside air replaces it quickly.
- Put the sensor in its own compartment, separated by a wall from the electronics.
- Give that compartment large openings for air exchange.
- Decouple it from heat sources. The guide names conduction through the PCB as the most common source of temperature error, so a separate small board or a wire lead beats mounting the sensor on the devkit.
In the enclosure, that means a small sensor bay with vent slots, a solid wall between the bay and the board chamber, and only a small hole in that wall for the sensor wires. A slot pattern is a few lines of OpenSCAD:
// snippet
// Vent slots: cut from the bay wall with difference().
module vent_slots(n, slot_w, pitch, slot_l, depth) {
for (i = [0 : n - 1])
translate([i * pitch, 0, 0])
cube([slot_w, slot_l, depth]);
}
Vents let in dust and insects as well as air. Do not describe a vented box as weatherproof or give it a protection rating unless it has been tested to the standard.
Print and check
Print the coupon first, then the base. Check the board drops into its pocket, the USB-C plug reaches the board with the cable’s overmould, and the lid closes without pressing on the module. Run lesson 6’s firmware before and after closing the lid and compare the logged RSSI over a few minutes. If the RSSI is consistently lower with the lid on, look at the lid’s distance from the antenna and its material. One reading is not a measurement, so repeat it and keep the board in the same place.
For makers
Use plain PETG or PLA for an indoor sensor and keep carbon-filled or metal-filled filaments away from the antenna. Size the box from the drawing, keep 15 mm around the antenna, print a tolerance coupon first, and put the sensor in its own vented bay. Start from the vented enclosure Build and change its parameters rather than drawing from scratch.
For product teams
The enclosure is part of the radio. Espressif’s guidelines call for testing the finished product’s throughput and range, so plan RF tests on the housed product, not the bare board. Freeze the material and its supplier once those tests pass: the paper above notes that the values vary with material purity, print settings and manufacturer. Material choice also involves flammability, UV and temperature requirements set by your product’s standards, which a printed prototype does not demonstrate. Moulded parts are solid where printed parts may not be, and the 25 % fill results show how much density matters, so repeat the RF check on production parts.
Exercise
- Download the DevKitC-1 dimension drawing (PDF or DXF) and check the five values in the first table against it.
- Print the tolerance coupon in the filament you plan to use. Record which slot fits a 2.0 mm thick test piece, and set
fitfrom that. - Work out
inner_landinner_wfrom the snippet with your ownfit, and compare them with the outer size of the Build page’s design.
Summary
- Take every dimension from the official drawing and datasheet, carry their tolerances, and mark measured values as assumptions.
- Keep all dimensions as named parameters with sources, and let
assert()enforce rules such as the antenna clearance. - Set the print clearance from a test coupon on your own printer.
- Keep at least 15 mm around the PCB antenna, free of metal, screws, wires and batteries, and use plain unfilled filament near it.
- Give the sensor its own small vented bay, walled off from the board’s heat.
Further reading
- ESP32-C5 Hardware Design Guidelines: PCB layout design, Espressif, Section 1.4.7 on module placement and housing clearance.
- ESP32-C5-DevKitC-1 dimension drawing v1.2 (PDF), Espressif.
- ESP32-C5-WROOM-1 datasheet v1.3, Espressif, Section 10 Physical Dimensions.
- W. Castro, D. Santos, L. Armas, E. R. Schlosser and M. V. T. Heckler, “Characterization of the Dielectric Properties of 3D Printing Filaments Using Cavity Perturbation Technique for 5G Applications”, Journal of Microwaves, Optoelectronics and Electromagnetic Applications, vol. 25, no. 2, 2026, doi:10.1590/2179-10742026v25i2298896.
- Design Guide for Humidity and Temperature Sensors, Sensirion, Version 2, March 2024.