Short answer: give the case 13 mm [0.5 in] of extra internal height for every HAT it will carry, and put the standoff pattern on the enclosure drawing before a single hole is cut. A HAT is a 65 x 56 mm [2.6 x 2.2 in] board that lands on the 40-pin GPIO header, spaced at least 8 mm [0.31 in] above the computer on its own spacers. The footprint rarely grows, because the computer underneath is still the bigger board at 85 x 56 mm — add-on boards break cases through height, not width. If you choose the case before you lay out the board, put this stack budget into that early choice.
What a HAT adds to the stack
The Raspberry Pi HAT+ specification, in its 2023 revision, governs add-on boards that sit on top of a Pi-format computer and connect through the full-size 40-pin header. Three of its numbers decide your enclosure:
- Footprint: 65 x 56 mm [2.6 x 2.2 in] of board — trimmed from the computer's own 85 x 56 mm, an area of 3640 mm² [5.6 in²].
- Spacing: the HAT sits at least 8 mm [0.31 in] above the computer, on spacers the specification calls for.
- Stacking: one HAT per computer. Stacking is left unsupported; only a board built with both male and female header sections passes the connector through for a second one.
That spacer exists to clear the header underneath, so treat it as the floor, not the target. Budget the per-board figure from the short answer above — the spacer plus 5 mm [0.2 in] for the board and the parts on its top face — and every pass-through board adds the same budget again. A pHAT keeps the length and halves the depth to 30 mm [1.2 in], but it lands on the same header, so it costs you the same height.
The height budget, layer by layer
| Layer, from the mounting face up | Height | Where the number comes from |
|---|---|---|
| Standoffs holding the computer | the standoff height you chose | keeps solder points and header tails off the metal |
| Spacer under the HAT | the specification minimum | clears the 40-pin header beneath the board |
| HAT board and its top-face parts | the parts allowance above | over terminal blocks and sockets |
| Lid clearance above the stack | 2 mm [0.08 in] | so the closed case presses on nothing |
| Total for one HAT | 20 mm [0.79 in] | standoff + per-board budget + lid |
Read the table as a budget: a standoff, one board-budget per add-on, and air at the top. Two pass-through boards push the same arithmetic to 33 mm [1.3 in]. The parts allowance covers the screw terminals many I/O boards carry; when a part on your board stands taller, measure it and use its height plus 1 mm [0.04 in]. Taller builds layer the same way — enclosures for stacked circuit boards works through those checks, and PC104 sizing for connectors and future expansion does the same for boards you have not bought yet.
The standoff pattern goes on the drawing first
Pi-format computers share one four-hole mounting pattern: 58 x 49 mm [2.3 x 1.9 in] between centers, 2.7 mm [0.11 in] holes for M2.5 hardware. Put those four holes on the enclosure drawing, tapped or fitted with standoffs, before you place any connector cutout. Once a HAT is bolted down it sits over the computer's mounting hardware, so holes added to a finished case land out of position and the board rides crooked on its header. The cutout designer takes the pattern on any face and checks its clearance to the walls in the same pass, on catalog sizes and custom sizes alike.
Sizing a case for an 85 x 56 mm computer with one HAT
This example sizes a wall-mount case for an 85 x 56 mm computer, one HAT fitted now, and a pass-through second board as a real possibility.
Inputs:
- Computer footprint: 85 x 56 mm [3.3 x 2.2 in] — the full board size the HAT documents name.
- HAT footprint: 65 x 56 mm, mounted at the specification spacing.
- Stack budget: one per-board budget per HAT — spacer plus board-and-parts allowance, as set out above.
- Standoffs and clearance: the table figures — a standoff under the computer, air at the lid — stated on the layout.
The rule in words: interior height equals the standoff, plus one board-budget per add-on board, plus lid clearance. Interior footprint equals the computer's board plus clearance on all four sides for airflow and handling.
The arithmetic:
- One HAT: standoff + budget + lid = 20 mm [0.79 in] of interior height.
- Second pass-through board: add one more budget = 33 mm [1.3 in].
- Length: 85 mm plus 0.2 in [5 mm] of side clearance each way = 95 mm [3.7 in]; width the same way = 66 mm [2.6 in].
Result: an interior of 100 x 70 mm [3.9 x 2.8 in] — the footprint rounded up — with 25 mm [1 in] of depth for the one-HAT build, or 35 mm [1.4 in] if the second board is likely.
Decision: below 20 mm of interior depth the case is single-board for its whole life; 20 mm carries one HAT; every extra per-board budget buys one more pass-through board. Depth is nearly free at the drawing stage and impossible to add to a finished case.
Steps from the stack to an approved drawing
- List the stack in mounting order — the computer, then each HAT or pHAT — with each board's footprint and its header type: pass-through or plain. The header type decides whether another board can follow.
- Add the heights: the standoff, one board-budget per add-on board, the lid clearance. Write the total on the layout.
- Mark the four mounting holes at the pattern centers given above, sized for M2.5 hardware, and state tapped holes or standoffs.
- Place connector cutouts against the computer's own edge connectors — power, USB, network — measuring from the mounting holes rather than the case edge.
- If any board carries a radio, plan its antenna against a plastic lid or an external connector; PCB antenna placement and clearance gives the keep-out distances.
- Send the layout for a quote: the enclosure builder carries the stack, the holes and the cutouts into the drawing you approve, and the finished case is delivered in 10 business days, counted from your approval of the drawing.
Cutouts, glands and the rating the case keeps
Connector windows are fine on a bench or inside a clean cabinet. On a plant floor, take the cables out through glands and keep the board connectors inside: a round gland hole seals under its rated gasket, a USB window does not. Bench and cabinet cases ask for a Type 12 rating against dust and dripping liquids; washdown asks for Type 4X, which is a job for a custom 304 stainless enclosure. Every NEMA type we build to is a manufacturer rating for the specified design; the enclosures are not UL listed. Sealed network runs follow gland sizing for an RJ45 connector, and the guide to cutouts, glands and display windows covers hole sizing in general.
Checks on the drawing before you approve it
Work through the enclosure drawing checks before fabrication on the drawing that comes back, starting with these:
- The four mounting holes at the pattern centers, with the hardware you asked for.
- Interior depth at least your stack total plus a hair — 0.79 in in the one-HAT example above.
- Cutout centers measured from the mounting holes to each connector, at the size the connector's own drawing states.
- At least 0.2 in from board edge to wall, more where a cable has to bend.
- On metal cases, every hole cut before coating, with a continuous gasket run around the door opening.
Mistakes that cost the fit
- Sizing to the bare computer with 3 mm [0.12 in] to spare — the first HAT bottoms out on the lid.
- Counting the header twice. The spacer already clears the 40-pin header, so each board costs its budget, not budget-plus-spacer.
- Drilling mounting holes into a finished case; they miss the pattern and the board strains its header.
- Leaving a radio antenna under a metal lid, where it loses most of its range. Bring it out through a plastic window or an external antenna connector.
Enclosures for this job
Catalog sizes that suit the job this article answers, picked from its subject; open one for its full specifications.
| Enclosure | Material | Outside H x W x D / display | Rating |
|---|---|---|---|
| 12 × 10 × 6 in | 304 stainless | 12 x 10 x 6 in | Rated NEMA 4X / IP66 by the manufacturer; not UL listed |
| 16 × 14 × 8 in | 304 stainless | 16 x 14 x 8 in | Rated NEMA 4X / IP66 by the manufacturer; not UL listed |
| 20 × 16 × 8 in | 304 stainless | 20 x 16 x 8 in | Rated NEMA 4X / IP66 by the manufacturer; not UL listed |
Questions
How much extra height does a HAT need inside the enclosure?
Budget 0.5 in above the computer for each HAT: the specification spaces the board at least 0.31 in up on its spacers, and 0.2 in more covers the board and the parts on its face. Add the same figure again for a second board only when the first has a pass-through header, plus 0.08 in of lid clearance at the very top of the stack.
Can I stack two HATs on the same single board computer?
The HAT specification leaves stacking unsupported, so plan one HAT per computer. The exception is a board built with both male and female header sections: it passes the 40-pin connector through, and a second board then adds another 0.5 in to the height budget, made up of its spacer and its clearance allowance.
Does a pHAT need less room than a full HAT?
Only in footprint. A pHAT keeps the 65 mm [2.6 in] length but halves the board to 30 mm [1.2 in] deep, so the computer underneath still sets the enclosure size. The height budget is the same half inch, because both formats land on the same 40-pin header.
Should the standoff holes be on the enclosure drawing I approve?
Yes. Send the four-hole pattern with the drawing: 58 x 49 mm [2.3 x 1.9 in] between centers, 2.7 mm [0.11 in] holes for M2.5 hardware, and say whether you want them tapped or fitted with 0.2 in standoffs. Holes drilled into a finished case are the usual reason a HAT sits crooked and strains its header.





