The Raspberry Pi HAT and pHAT Ecosystem Explained: Choosing and Stacking Add-On Boards
The Raspberry Pi's 40-pin GPIO header is the reason the platform has such a deep add-on ecosystem, but "just wire it up yourself" isn't always the best answer — a well-designed add-on board handles power regulation, connector strain relief, and mechanical fit in ways a breadboard and jumper wires never will. This guide explains the HAT specification and its variants, how to tell them apart, and how to choose the right add-on board instead of accidentally buying one that doesn't fit your Pi or conflicts with another board you're already using.
What Makes a Board a "HAT"
HAT stands for Hardware Attached on Top, and it's an actual specification, not just a marketing term for "any GPIO board." A board that's genuinely HAT-compliant must meet several requirements the Raspberry Pi Foundation defined specifically to make add-on boards safely auto-configurable:
- Correct board outline and mounting holes matching the official Pi form factor, so the HAT lines up with the Pi's mounting standoffs.
- An EEPROM containing an ID string that tells Raspberry Pi OS what the board is and what GPIO pins and drivers it needs, enabling auto-configuration without manual setup on genuinely compliant boards.
- A defined power budget the board is allowed to draw from the Pi's 5V rail without external power, and clear labeling when it needs its own supply.
- GPIO pin usage documented against the standard pinout so users can tell at a glance which pins a HAT claims before stacking a second board that might conflict.
Many popular "HAT" boards on the market are HAT-shaped (correct outline and header) but skip the ID EEPROM — these work fine but require manual driver setup rather than being auto-detected. That's a meaningful practical difference even though the physical board looks identical.
HAT, pHAT, and the Size Variants
| Form factor | Fits | Notes |
|---|---|---|
| HAT | Full-size Pi (3, 4, 5, and full-size Zero-compatible headers) | Full 65mm x 56mm outline, standard mounting holes |
| pHAT | Pi Zero and Zero 2 W primarily, also fits full-size Pis | Half-size — 65mm x 30mm — designed to keep a Zero-based build compact |
| Bonnet | Any Pi with a 40-pin header | Adafruit's naming for their HAT-shaped boards; functionally the same idea, not an official spec term |
| Zero HAT / Zero pHAT | Pi Zero form factor specifically | Some vendors explicitly size boards to match the Zero's smaller footprint even when electrically identical to a full HAT |
The practical rule: a full-size HAT will physically fit on any 40-pin Pi, but a Pi Zero build with a full-size HAT stacked on top loses the whole point of using a Zero in the first place — check for a pHAT-sized version if board footprint matters for your enclosure.
Stacking Multiple HATs
This is where most HAT-related problems actually happen. Two HATs that each use I2C, or that both claim the same GPIO pin for something like a chip-select or reset line, will conflict the moment you try to stack them. Before combining boards:
- Check documented pin usage for every board — most vendors publish a pinout diagram; cross-reference before assuming two boards will coexist.
- I2C and SPI devices can usually share a bus as long as each device has a distinct address (I2C) or its own chip-select line (SPI) — the real conflicts are almost always around dedicated GPIO pins used for interrupts, resets, or enable lines rather than the bus lines themselves.
- Stacking headers exist for a reason. A pass-through (stacking) header lets a second HAT sit above the first while both still reach the Pi's pins — but only works if neither board physically blocks components on the one below it, which is a real issue with boards that have tall components like RTC coin cell holders or large connectors.
- Power budget adds up. Each HAT drawing power from the Pi's 5V rail eats into the same supply — a Pi already running a display HAT and an audio HAT off the header, with no auxiliary power, is a common cause of brownouts and random reboots that look like software bugs but are actually power delivery problems.
Common HAT Categories and What to Look For
| Category | Examples | What to check before buying |
|---|---|---|
| Power (PoE, UPS) | Official PoE+ HAT, UPS HATs with 18650 cells | Fan compatibility with your Pi's case, and whether it passes GPIO through for further stacking |
| Displays | Official touchscreen, small SPI TFT HATs, e-ink HATs | Whether it needs the full header or leaves pins free for other HATs underneath |
| Audio | DAC HATs (HiFiBerry, IQaudio), I2S microphone HATs | Whether it disables onboard audio/HDMI audio, and driver support for your OS version |
| Motor/relay control | Motor driver HATs, relay HATs | Whether it needs a separate motor supply — most motor HATs should not run motors off the Pi's own 5V rail |
| Sensor/GPIO expansion | ADC HATs, environmental sensor HATs, breakout HATs with prototyping area | Bus type (I2C vs SPI) and whether addresses are configurable if you'll want more than one |
| Real-time clock | RTC HATs with coin-cell backup | Physical height — coin cell holders often prevent flush stacking of a second board |
When to Build Your Own Instead of Buying a HAT
A generic prototyping HAT (a bare board with a breadboard-style GPIO breakout and open row) is often the better answer when your needs are simple and specific — it costs less than a purpose-built HAT and avoids paying for features you won't use. For anything more involved, a custom HAT is a natural extension of the PCB design skills already covered in this site's KiCad and JLCPCB ordering guides — designing your own gives you the exact pin mapping, mounting, and power handling your project needs, and following the official HAT EEPROM spec means your board gets the same auto-configuration convenience as a commercial one.
Choosing an Approach
Buy a purpose-built HAT when a well-supported one already exists for your exact need — PoE, a display, audio, an RTC — since the driver support and documentation save real setup time over a from-scratch build. Reach for a generic prototyping HAT plus your own wiring when your need is narrow enough that a full purpose-built board is overkill. Design a custom HAT when you're combining several functions that no single commercial board covers, or building something meant to be reproduced and shared with others.