DIN rail enclosure, 3D printed: a case for a PCB, relay or Shelly that clips onto a 35 mm rail
The clip geometry that snaps onto a 35 mm DIN rail, module widths in 17.5 mm steps, terminal access, and a prompt for a rail-mounted ESP32 or relay housing.The rail
A standard top-hat DIN rail is 35 mm wide and 7.5 mm deep (15 mm on heavy versions). Devices clip onto its two lips. Widths of commercial modules come in multiples of 17.5 mm, so a 2-module device is 35 mm wide and a 4-module one is 70 mm. Matching those widths keeps a printed case tidy in a consumer unit.
The clip
A printed clip has a fixed hook on one side and a sprung latch on the other:
- Hook: a 1.5 mm lip that catches the top rail edge
- Latch: a 1.2 mm thick cantilever, 20 mm long, with a 45° lead-in and a 1 mm lip, that flexes over the bottom edge
- Rail slot: 35.4 mm between the hook and the latch face, 7.8 mm deep
Print the clip with the cantilever lying flat (in the plane of the layers) so it flexes along the layer lines instead of snapping across them. PETG lasts longer than PLA here. The AI orients it correctly when you ask for a DIN clip.
Two ways to build
- A DIN adapter plate that a device screws or clips onto: fastest, works with any existing case, for a Shelly or a bare sensor board.
- A DIN enclosure with the clip on the back and the board inside, modular width, terminals reachable from the front.
The prompt (enclosure)
The prompt (adapter)
Home automation modules
Shelly, Sonoff and Zigbee devices are the usual suspects. The library has a Shelly 2PM Gen3 DIN adapter and a Home Assistant Yellow DIN rail clip ready to open. Give the device's outline and it gets a pocket on the plate.
Safety
Mains wiring belongs in enclosures rated for it. A printed housing is fine for low-voltage boards and for holding a mains device that already has its own insulated case. Keep 8 mm creepage between low-voltage and mains terminals if both are in one box, and ask for an internal wall.
Prompts to start from
Open one in the builder, change the numbers to yours, and the model renders in seconds. Keep adjusting in the chat before you print.A 4-module DIN rail enclosure, 70 mm wide, 90 mm tall, 58 mm deep, for an ESP32 DevKit (55 x 28 mm, no holes, edge rails) and a 2-channel relay board (50 x 38 mm, 3 mm corner holes). 2 mm walls, a DIN clip on the back for a 35 mm rail with a 1.2 mm sprung latch, two 25 x 8 mm terminal openings on the front face, a micro USB cutout on the side, hex vents on top, screwed front cover with M3 pillars.
A DIN rail adapter plate 60 x 40 x 4 mm with a clip for a 35 mm rail on the back, a 1.5 mm fixed hook and a 20 mm long sprung latch, and four 3.2 mm holes on a 45 x 30 mm pattern on the front for a small PCB.
A 2-module DIN rail case, 35 mm wide, 90 mm tall, 60 mm deep, for a Raspberry Pi Pico on 2 mm pegs (47 x 11.4 mm) and a 4-way screw terminal block reachable from the front, DIN clip on the back, micro USB cutout on top, snap-fit front cover.
Questions
Yes for light devices. A 1.2 mm PETG cantilever with a 1 mm lip holds a few hundred grams and survives many cycles. Print the latch flat so it bends along the layers, and use PETG rather than PLA in a warm cabinet.
A multiple of 17.5 mm: 35 mm for 2 modules, 52.5 for 3, 70 for 4. The generator rounds to that when you say the module count.
Put mains devices that already have their own rated insulation on a printed plate or in a printed housing; keep bare mains terminals in a rated enclosure. For mixed boxes, keep 8 mm between mains and low-voltage parts and ask for an internal wall.
