Raspberry Pi: the mounting-hole pattern and the HAT

10 min readUpdated Jun 2026

You have a Raspberry Pi on the bench and you want to print an enclosure for it, or a plate of standoffs to hold it inside a larger build. The temptation is to measure the four holes with callipers and work from there. Don't: those holes are standardised, they share dimensions across models, and they belong to an ecosystem — the HAT — that expects you to honour the pattern to the millimetre. The hard part isn't drawing four posts; it's that a printed standoff with a hole for an M2.5 never comes out the size you drew, and if you pick the wrong model the whole pattern falls apart. It pays to start from the real dimensions and translate them into FDM clearance before you touch the model.

The hole pattern: 58 × 49 and M2.5

The Raspberry Pi 4 Model B and the 3B+ share exactly the same mounting pattern: four holes at the corners of a 58 × 49 mm rectangle, measured centre to centre. Each hole is 2.7 mm in diameter, sized for an M2.5 screw (not M3: an M3 won't pass, and forcing it cracks the board). The centres don't sit in the middle of the PCB: they land 3.5 mm from two adjacent edges, so the hole rectangle is tucked into one corner. On the 56 mm short axis you get 3.5 mm on each side, but on the 85 mm long axis you have 3.5 mm at one end and 23.5 mm at the other — the USB and Ethernet port side. Don't assume the pattern is centred on the board: it isn't.

Those are the dimensions you take to the model, and they belong to the board, not to your part. You copy the 58 × 49 mm centre-to-centre spacing verbatim, with no clearance — the centres of your standoffs go exactly there, because an error in one post's position misaligns all four and the board won't sit flat. The 2.7 mm is a different matter: it's the through-hole diameter in the PCB, which only concerns you if the screw passes through the board into your standoff.

Mounting pattern — Raspberry Pi 4 Model B and 3B+
Dimension Value Notes
Hole rectangle (centre to centre) 58 × 49 mm identical on 4B and 3B+
Hole diameter in the PCB 2.7 mm through-hole for M2.5
Hole centre to nearby edges 3.5 mm two adjacent edges only; not centred
Board size 85 × 56 mm outer PCB outline
Screw M2.5 does not take M3

Not every Pi shares this pattern

Here's where you have to be honest: "Raspberry Pi" isn't a single dimension. The 58 × 49 mm pattern holds for the 4B and the 3B+ (and for several earlier full-size boards), but not for the whole family. The Pi Zero and Zero 2 W have a much smaller pattern, 58 × 23 mm between holes, on a 65 × 30 mm board. The Pico doesn't even share the concept: its holes are 2.1 mm and sized for M2, with its own pattern, 47 × 11.4 mm. Industrial boards (Compute Module, carrier-board variants) change entirely.

If your board is a 4B or a 3B+, the table above is all you need. If it's anything else, measure it or check its mechanical datasheet before you print. Don't carry the 58 × 49 mm over to a Zero: the holes won't land where you think, and finding that out with the enclosure already printed is expensive. The pattern depends on the model, so confirm it before you commit to a dimension.

The HAT: 65 × 56 mm over the same holes

HAT expansion boards (Hardware Attached on Top) stack on top of the Pi using those same four holes. The HAT standard defines a 65 × 56 mm footprint with rounded corners, and conveniently, its mounting holes line up with the base board's 58 × 49 mm pattern. Standoffs go between the Pi and the HAT: they fix the vertical gap and share the mechanical load of the connector.

That connector is the other dimension you can't ignore: the HAT connects through the Pi's 40-pin header (GPIO), a 2 × 20 comb at 2.54 mm pitch that stands proud of the board plane. If you design a standoff plate or an enclosure that sits between the Pi and the HAT, you have to leave a through opening for that 40-pin connector; cover it and the HAT won't seat, and you'll strain the pins. And make sure the standoff height matches the connector length: if the posts are shorter than the depth the comb can reach, the female connector bottoms out on the pins before it reaches the posts and the HAT hangs off the header instead of resting on the plastic; if they're too tall, the HAT sits on the posts but the pins barely engage and electrical contact suffers.

Printed standoffs: the hole comes out small

This is where the FDM bias comes in, and it always runs the same way. A standoff you print with a 2.5 mm hole for an M2.5 does not come out at 2.5 mm: it comes out narrower. Holes shrink — as explained in Real printed clearances. The inner perimeter lays its bead toward the inside of the circle and the contour's geometric compensation closes the diameter along the whole bore; first-layer squish (elephant's foot) only narrows it further at the bottom opening. A nominal 2.5 mm hole can end up at a real 2.2–2.3 mm, and at that size an M2.5 neither enters nor threads cleanly.

You have two routes. If the screw only passes through the standoff (thread at the far end), give it clearance: model the through-hole at 2.8–3.0 mm so an M2.5 crosses without binding. If you want the standoff to take a thread directly in the plastic, bear in mind that a self-tapping thread cut in PLA in a small hole survives only a few open-and-close cycles before it strips. For a joint you'll assemble and disassemble, or one that takes torque, the reliable answer is a heat-set insert for M2.5: you model a boss with the hole for the insert, seat it hot by melting the plastic with a soldering iron, and get a durable metal thread. How to size that boss and the insert hole is in Designing for heat-set inserts.

Orientation: standing posts, and a shell that won't split

How you orient the part on the bed decides whether the holes come out round. Print the standoffs vertically, with the hole axis perpendicular to the bed: that way the hole builds up layer by layer as a closed circle and comes out cylindrical. A standoff lying down prints its hole horizontally, with no support inside, and that hole comes out oval and sagging at the top — a distortion you won't fix by opening up the diameter. It also leaves the insert's thread working against the layer lines. That's the compelling reason to print them standing: the roundness of the hole.

That said, don't fool yourself about load. In a standing post the layer lines sit perpendicular to the screw axis, so when you tighten — or when the insert pulls outward — the axial tension acts normal to the layers, right along FDM's weak interlaminar direction. Melting the insert in, on top of that, introduces hoop stress that tends to split the boss along the bead joints. A vertical post is, if anything, the most vulnerable to insert pull-out. The standing orientation is forced on you by the roundness of the hole, not by strength; what really armours the boss against pull-out is thickening the wall around the insert and not over-torquing on assembly — not hunting for a magic orientation.

For the enclosure, orientation decides stiffness. A thin-walled shell printed upright has its layers horizontal, and a tall, thin wall yields and splits right where the layers separate. Orient the enclosure so the walls that hold the board work in the plane of greatest adhesion, and if a long wall tends to buckle, thicken it or add a rib rather than trusting more perimeters. Interlayer adhesion is the variable that decides whether the enclosure survives a tug on the power cable.

Ventilation and access: cutouts per model

A sealed enclosure thermally chokes a Pi 4, which already runs warm. Leave ventilation grilles or cutouts over the SoC and, if you'll work it hard, an opening for a 30 or 40 mm fan. And don't forget port access: the USB, HDMI, Ethernet, microSD slot and audio jack connectors come out at the edges, and their positions and sizes depend on the model. The Pi 4 carries two micro-HDMI and a USB-C for power; the 3B+ carries a full-size HDMI and micro-USB. The cutouts for one don't work for the other.

Port dimensions aren't worth quoting here: they vary from one revision to the next, and pinning down a number with false precision would be worse than leaving it out. Measure the connectors on your board — or take the dimensions from its mechanical drawing — and add 0.5–1.0 mm of clearance per side to each cutout, so the cable enters without rubbing and the FDM bias doesn't close the opening on you. A port cutout that comes out 0.3 mm too narrow is a connector that won't plug in.

With the pattern confirmed for your specific model, the standoffs oriented standing up and the cutouts measured on the real board, the enclosure fits first time. If your project mounts a different board, the method is the same even when the numbers change: see Arduino: the Uno, Mega and Nano footprints for the other big board ecosystem, or go back to Designing for heat-set inserts to nail the M2.5 thread that will survive every disassembly.