Design story

An ESP32 sensor box with heat-set inserts, a vented lid and a sliding PCB tray

One prompt gave me a three-part ESP32 enclosure: a base with M3 heat-set inserts, a PCB tray that slides in on grooves and a vented lid. I typed a sensor window into the code by hand, and the agent picked up my edit on the next turn and built on it. The board size, standoffs and USB opening are all sliders, so you can fit it to your own board.

On this page
  1. The plan: a box you open without unscrewing the board
  2. Turn 1: the whole box from one prompt
  3. Turn 2: I edited the code myself
  4. Turn 3: the agent builds on my edit
  5. Inside the box
  6. Fit it to your own board
  7. Printing and assembly
  8. Sources and method

Key takeaways

  • One prompt made all three parts. In 4 minutes Opus wrote 207 lines of OpenSCAD: a base with four Ø4.0 × 6 mm heat-set insert holes, a tray that slides on 1.2 mm grooves and a lid with countersunk screws. It came with 13 named features and 13 sliders.
  • You can edit the code yourself, and the agent keeps your edit. I typed a sensor window into the code editor in Advanced mode. It rendered straight away, with its own feature chip and four new sliders, and no AI call.
  • The next turn built on my code. Asked for a twin window and wall-mount keyholes, Opus kept my parameter names, my feature name and my comment, and wrapped my one cut in a loop instead of rewriting it.
  • Check what the agent assumed. My prompt never said how high the USB port sits, so the agent used 6 mm and listed it under "Defaults adopted". With an ESP32 DevKit on headers, the port sits at 11.7 mm. One slider fixes it.
  • 83 minutes and 46 g of PLA for all three parts, with no supports. Add four M3 inserts, four M3 × 6 countersunk screws and four M2 self-tapping screws.

The plan: a box you open without unscrewing the board

Most ESP32 projects in our Arduino and ESP32 build guides end the same way: a perfboard with a dev board and a sensor on it, and nowhere to put it. A snap-fit case, like the Raspberry Pi 5 case in our Kimi vs Opus vs Astra test, is great for a board you set up once. A sensor box needs something different: a lid you can take off over and over, and a board you can lift out to reflash or rewire.

So this box has three parts. The lid screws into brass heat-set inserts, which survive being opened many times, unlike screws driven straight into plastic. The board sits on a tray that slides out of the back on grooves, so you never unscrew the board to get at it. The base has vents low on both sides and in the lid, so air can flow past the sensor.

All of it happened in one chat on Claude Opus 5.5 with Advanced mode on. Advanced mode adds a code editor next to the chat, and this story is mostly about what happens when you use it.

One chat, two AI turns
StepWho did itAI turnsTime
Base, tray and lid from one promptOpus14 min 7 s
A sensor window typed into the codeMe, in the code editor0instant render
A twin window and wall-mount keyholesOpus, building on my edit12 min 41 s

Times are from the chat's own timers. Each Opus turn costs 3x a Kimi message.

Turn 1: the whole box from one prompt

I wrote the prompt the way I would brief a person: what each part does, every size I know, which hardware goes where, and which numbers should be sliders. The insert hole is the standard size for M3 heat-set inserts (Ø4.0 mm, 5.7 mm long), with 0.3 mm extra depth so the insert can sit below the surface.

AI CAD agent Claude Opus 5.5 · 3x

Design a three-part enclosure for an ESP32 sensor board: a base box, a sliding PCB tray and a vented lid. My board is a 50 x 70 mm perfboard (1.6 mm thick) with an ESP32 dev board and a BME280 soldered on; the tallest part is 15 mm above the board. It has four 2 mm mounting holes, 3 mm in from each edge. The tray is a 2 mm plate with four 5 mm tall standoffs (M2 self-tapping pilot holes) under those holes. It slides into the base along grooves in the two long walls through an open back end, and has its own back wall that closes that end when it is pushed home. The board's USB-C port faces the front wall, so cut a 12 x 7 mm opening there, centred on the board by default. The lid screws down with four M3 screws into heat-set inserts: put 4.0 mm wide, 6 mm deep insert holes in 8 mm bosses in the base corners, keeping the bosses clear of the tray's path, with countersunk M3 clearance holes in the lid. Add vent slots in the lid over the board and a row of low vent slots in both long walls so air flows past the sensor. 2 mm walls and 1 mm clearance around the board. Make the board size, the mounting hole positions, the standoff height and the USB opening's position and size sliders, so other people can reuse this box for their own board. Lay the three parts out side by side, each oriented to print without supports.

The last two sentences matter most: "make these sliders" and "print without supports".
The CAD agent chat with the long enclosure prompt and Opus thinking at 47 seconds about giving the outer shape boss ears at the corners so the walls stay thin
Thinking at 47 s: putting the bosses in ears at the corners, and noting that the lid has to follow the same outline.
Attempt 1

Three parts, 13 features, laid out to print

  • AI CAD agent
  • Claude Opus 5.5 · 3x
The CAD agent with the base, tray and lid laid out side by side in the viewer, an 8 of 8 done checklist and thirteen feature chips from groove_ribs to vented_lid
The result: 13 feature chips, one for each // @feature: marker in the code.
Time
4 min 7 s
Code
207 lines, 13 features
Sliders
13, plus 3 colours
Layout
199.8 × 78.2 × 28.6 mm
Base
68 × 76 × 28.6 mm

Opus put the four insert bosses in "ears" on the outside corners, so the inside of the box is a clean 52 × 72 mm channel for the tray. Each groove takes 1.2 mm out of the 2 mm wall, so it added a 45° rib on the outside to bring the wall back to 2 mm there. The lid got a 3 mm skirt at the back that stops the tray sliding out while the lid is on.

What worked
  • Every number from the prompt is in the code: 4.0 × 6 mm insert holes, Ø1.6 M2 pilots, 2 mm walls and 1 mm clearance.
  • The design brief listed what it would check before writing any code: 4 insert holes, 4 countersunk holes, 4 pilot holes, 18 side vents and 12 lid vents.
  • It warned that the layout is just under 200 mm wide and fits a 220 mm bed.
What did not
  • The USB opening sits 6 mm above the board, which is a guess. My prompt never said how high the port is. It is listed under "Defaults adopted", and I come back to it below.
  • The low side vents sit mostly below the board. That is fine for airflow, but none of them are next to the sensor, which is what my hand edit fixes next.

Turn 2: I edited the code myself

The BME280 sits near the left wall, and an ESP32 runs warm. A temperature sensor in a closed box mostly measures the chip next to it, so I wanted an opening right beside the sensor. It is a small cut, so instead of asking for it I opened the Code pane and typed it in.

esp32_box.scad · my hand edit
// added to the parameters at the top: each one becomes a slider
// Sensor window: position along the left wall (+Y = back)
sensor_window_y = 20;
// Sensor window: centre height above the board top
sensor_window_z = 6;
// Sensor window length along the wall
sensor_window_length = 14;
// Sensor window height
sensor_window_height = 6;

// added inside base_box(), after the side vents
        // @feature: sensor_window
        // open slot beside the BME280 so it reads room air, not the ESP32
        translate([-(cavity_width / 2 + wall_thickness / 2), sensor_window_y,
                   board_top_z + sensor_window_z])
            cube([wall_thickness + 2 * groove_depth + 2, sensor_window_length, sensor_window_height],
                 center = true);

Four parameters at the top of the file and a six-line cut in base_box(). I copied the style of the agent's own code: a comment above each parameter and a // @feature: marker.

When I stopped typing, the model re-rendered, going from 7,530 to 7,550 triangles. Because I followed the file's conventions, the page treated my code like the agent's. The // @feature: sensor_window line became a chip, and the four commented numbers became sliders in the Params tab. No AI was involved.

The CAD agent with the code pane open on the hand-typed sensor_window block, and a new sensor_window chip among the feature chips above the chat
My block in the Code pane, and a sensor_window chip in the feature list.

Turn 3: the agent builds on my edit

Next I wanted the same slot on the other side, so air flows straight across the sensor instead of into a dead end. I also wanted a way to hang the box on a wall. I clicked my new chip, which put @feature[sensor_window] in the message, and pointed at my own code:

AI CAD agent Claude Opus 5.5 · 3x

@feature[sensor_window] I added this slot by hand, next to the BME280. Give it a twin in the right-hand long wall so air can flow straight across the sensor, driven by the same sensor_window sliders. Then add two wall-mount ears to the base with keyhole slots for 4 mm screws, placed where they do not block the tray, the vents or the USB opening, so the box can hang on a wall.

"Driven by the same sensor_window sliders" asks it to reuse my parameters, not invent its own.
Attempt 2

My window, twinned, plus keyholed ears

  • AI CAD agent
  • Claude Opus 5.5 · 3x
The CAD agent viewer showing the base with keyhole ears on both sides, and a 10 of 10 done checklist ending with Edited model +48 −5, 8,682 tris, 158.4 × 156.9 × 28.6 mm, 2 m 41 s
New chips: wall_mount_ears and wall_mount_keyholes. sensor_window is the same chip as before.
Time
2 min 41 s
Change
+48 / −5 lines
Layout
158.4 × 156.9 × 28.6 mm
New sliders
mount_screw_diameter, mount_ear_y
My 4 sliders
kept as written

Opus did not rewrite my window. It wrapped my translate in a two-step loop that mirrors it to the right wall, kept my comment and added one of its own below it. For the ears, it put a 3 mm plate on each long wall at floor level with a keyhole slot. That is below the vents (which start at Z 7.3 mm), in the middle of each wall and outside the tray's path. The layout became two columns, which brought it down from 200 mm wide to 158 mm.

What worked
  • My four parameter names, their values, the feature name and my comment are all unchanged.
  • The only change it made to my lines was the comment "the left wall", which became "both long walls". That is correct now.
  • The keyhole slot runs from the head hole toward the back, because the box hangs USB-down. The brief explained why.
What did not
  • The ears stick out about 9 mm on each side, so the box is 85 mm wide on the wall instead of 68 mm.
  • The box hangs with its floor flat against the wall, so the screw heads have to be set about 4 mm proud before you hang it. The brief says so, but it is easy to miss.
esp32_box.scad · after turn 3
// Sensor windows: position along both long walls (+Y = back)
sensor_window_y = 20;

        // @feature: sensor_window
        // open slot beside the BME280 so it reads room air, not the ESP32
        // (twinned in both long walls for straight cross-flow over the sensor)
        for (s = [-1, 1])
            translate([s * (cavity_width / 2 + wall_thickness / 2), sensor_window_y,
                       board_top_z + sensor_window_z])
                cube([wall_thickness + 2 * groove_depth + 2, sensor_window_length, sensor_window_height],
                     center = true);
        // @feature: wall_mount_keyholes
        for (sx = [-1, 1])
            translate([sx * mount_keyhole_x, mount_ear_y, -1])
                linear_extrude(height = mount_ear_thickness + 2) keyhole_2d();

My block, wrapped in for (s = [-1, 1]). The wall_mount_keyholes feature is new.

After turn 3: Drag to compare the base with one hand-typed sensor window and the base after the agent added the twin window and the wall-mount ears
My hand edit: Drag to compare the base with one hand-typed sensor window and the base after the agent added the twin window and the wall-mount ears
My hand edit After turn 3
Same camera, same scale. Before: my one window, on the far wall. After: its twin on the near wall, and the keyhole ears at floor level.
esp32_box.scad · keyhole_2d()
// keyhole: head hole at -Y, slot runs toward +Y (box hangs USB-down)
module keyhole_2d() {
    translate([0, -mount_slot_travel / 2]) circle(d = mount_head_diameter);
    hull() {
        translate([0, -mount_slot_travel / 2]) circle(d = mount_slot_width);
        translate([0,  mount_slot_travel / 2]) circle(d = mount_slot_width);
    }
}

Sized from one slider: a Ø9 head hole and a 4.5 mm slot for a 4 mm screw, 7 mm of travel.

Inside the box

Renders show the outside. To check the inside, I cut the assembled box in two places, with the stand-in board on the tray and the lid on.

Two cross-sections of the assembled box. The top one cuts through the corner bosses and shows the insert holes, the countersunk lid holes and the tray plate in its grooves. The bottom one cuts through the sensor windows, the purple BME280 and the ESP32 dev board on its headers.
Top: through the corner bosses. Bottom: through the sensor windows, with the BME280 beside the left one.
  • Insert bosses. The Ø8 boss leaves 2 mm of plastic around the Ø4.0 hole, which is the usual minimum for an M3 heat-set insert. The holes are 6 mm deep, so the 5.7 mm insert sits just below the surface.
  • Grooves. The tray plate runs in 1.2 mm grooves with 0.3 mm clearance on each side. With the lid off it slides all 80 mm out without touching anything. I checked this in 5 mm steps.
  • The lid locks the tray. With the lid on, the tray's back wall hits the lid's 3 mm skirt after about 0.2 mm of travel, so the tray cannot slide out.
  • Nothing collides. Assembled, the base, tray, lid and stand-in board overlap by 0 mm³.
  • Air path. The 18 side vents sit low, mostly beside and below the board, and 12 slots in the lid sit above it. Warm air from the ESP32 can rise out of the lid while room air comes in at the sides and through the sensor windows. I have not measured this; it is just how the openings are placed.

Fit it to your own board

This is what the sliders are for. In the Params tab, the board size, mounting hole insets, standoff height and the USB opening each have a slider and a typing box. The base, the grooves, the tray, the bosses, the vents and the lid are all calculated from them.

board_width and board_length, from a 50 × 70 to a 70 × 90 mm perfboard. The walls, bosses, vents and standoffs all follow.
The Params tab with sliders for perfboard width 50, length 70, thickness 1.6, tallest component 15, hole insets 3 and 3, standoff height 5 and the USB opening, next to the base and lid in the viewer
Key dimensions first, then everything else. Moving a slider re-renders in under a second, with no AI call.

Now the USB port. My prompt said "centred on the board" but gave no height, so the agent set the opening's centre 6 mm above the perfboard and listed it under "Defaults adopted". On my stand-in, the DevKit sits on 8.5 mm female headers. That puts the port's centre 11.7 mm above the perfboard, and the opening misses it completely.

Set to 11.7 mm: Drag to compare the front of the closed box with the USB opening at the default height, showing only the perfboard behind it, and at 11.7 mm, showing the silver USB-C port
Default: 6 mm: Drag to compare the front of the closed box with the USB opening at the default height, showing only the perfboard behind it, and at 11.7 mm, showing the silver USB-C port
Default: 6 mm Set to 11.7 mm
Same camera. At 6 mm you see the perfboard through the hole. At 11.7 mm the USB-C port sits in the middle of it.

One slider fixes it. To make the fix permanent in the code, type it as a chat line. A message that is only name = value pairs is applied in the browser without calling the AI:

AI CAD agent

usb_center_above_board = 11.7

Typed as a normal chat message. Free, and it survives the next edit.

The same goes for a port that is not centred. The usb_offset_x slider starts at 0, so a port left of centre needs a negative number. Type usb_offset_x = -6 (or whatever you measure) the same way.

What to measure, and where it goes
Your boardSliders to change
A different perfboard or PCBboard_width, board_length, board_thickness
Mounting holes not 3 mm from the edgehole_inset_x, hole_inset_y
Something taller (an OLED on headers, a big capacitor)component_height
DevKit on headers, or soldered flatusb_center_above_board: port centre above the board
Micro-USB, or a plug with a big bootusb_width, usb_height
Sensor somewhere else along the wallsensor_window_y, sensor_window_z
Thicker wall screwsmount_screw_diameter

Sources and method

Made on November 29, 2026, in one CAD agent chat on a PrintPal Pro account, with Claude Opus 5.5, Advanced mode and Auto-improve on. The prompts are shown above, unedited. The hand edit was typed into the page's code editor and is shown in full. Times are from the chat's timers. The OpenSCAD for each version and the chat text were saved straight from the page, and the claims about what each turn kept or changed come from line diffs between those files. Renders, animations and cross-sections are those files rendered with OpenSCAD's manifold backend, with a stand-in board (a 50 × 70 mm perfboard, an ESP32 DevKit on 8.5 mm headers and a BME280 breakout) modelled from typical sizes. Overlaps and the tray's slide path were measured as mesh intersections. Print times and filament are Bambu Studio estimates for an X1 Carbon at 0.20 mm in PLA. Nothing has been printed. PrintPal makes the CAD agent.

  1. PrintPal AI CAD agent
  2. ESP32-DevKitC user guide
  3. Bosch BME280 product page
  4. OpenSCAD documentation
  5. Bambu Studio

Spotted something out of date? Tell us and we will re-check it.

Your board, your box

Describe the board and the hardware you have, ask for sliders, then make small edits yourself and let the agent build on them.