Designing a Raspberry Pi HAT PCB follows the official HAT (Hardware Attached on Top) specification that ensures mechanical compatibility, automatic configuration, and a professional finish. Whether you are building a custom sensor board, motor controller, or industrial interface, this tutorial covers the complete HAT design process from dimensions to ID EEPROM.
Table of Contents
- HAT Specification Overview
- Mechanical Dimensions
- GPIO Header Layout
- ID EEPROM (Optional)
- Design Guidelines
- Example: Sensor HAT Design
- Frequently Asked Questions
- Conclusion
HAT Specification Overview
The Raspberry Pi HAT specification defines:
- Board dimensions (65×56.5mm) matching the Pi’s mounting holes
- 40-pin GPIO header location and keep-out zones
- Mounting hole positions for the 4 standoff pillars
- Optional ID EEPROM for automatic driver loading
- Power requirements and GPIO usage rules
Following the HAT spec ensures your board physically fits, does not interfere with ports, and can optionally auto-configure when plugged in.
Mechanical Dimensions
- Board size: 65 x 56.5mm (can be shorter in Y direction but not wider)
- Mounting holes: 4x M2.5 at positions (3.5, 3.5), (3.5, 52.5), (61.5, 3.5), (61.5, 52.5) mm from bottom-left corner
- GPIO header: 2×20 pin, 2.54mm pitch, positioned at (29, 50.5) mm centre of pin 1
- Height: Components on top should be under 12mm to allow stacking
- Corner radius: 3mm rounded corners
GPIO Header Layout
The 40-pin GPIO provides access to power, I2C, SPI, UART, and general-purpose I/O:
- Power pins: 5V (pins 2,4), 3.3V (pins 1,17), GND (pins 6,9,14,20,25,30,34,39)
- I2C: SDA (pin 3, GPIO2), SCL (pin 5, GPIO3). Also used for ID EEPROM
- SPI: MOSI (pin 19), MISO (pin 21), SCLK (pin 23), CE0 (pin 24), CE1 (pin 26)
- UART: TX (pin 8, GPIO14), RX (pin 10, GPIO15)
- ID EEPROM: Dedicated I2C bus on ID_SD (pin 27) and ID_SC (pin 28)
ID EEPROM (Optional)
The HAT ID EEPROM stores device tree overlay information that automatically configures the Pi when your HAT is plugged in. This is optional for hobby projects but required for official HAT compliance. Use a CAT24C32 or similar 32Kbit I2C EEPROM connected to the dedicated ID_SD and ID_SC pins (GPIO0 and GPIO1).
Design Guidelines
- Use KiCad or EasyEDA HAT templates for correct dimensions
- Place the 40-pin header first and lock its position
- Keep the area around the Pi’s camera and display connectors clear
- Route I2C and SPI traces with appropriate pull-ups
- Add status LEDs connected to spare GPIO pins
- Include reverse polarity protection if the HAT provides external power to the Pi
Example: Sensor HAT Design
A basic sensor HAT might include:
- BME280 temperature/humidity/pressure sensor (I2C)
- ADS1115 16-bit ADC for analog inputs (I2C)
- Status LED on GPIO17
- Screw terminal for external sensor connections
- ID EEPROM for auto-configuration
This design uses only 4 GPIO pins (I2C + LED + ID EEPROM), leaving the rest available for other purposes or stacked HATs.
Frequently Asked Questions
Can I make a HAT for the Raspberry Pi 5?
Yes, the Pi 5 uses the same 40-pin header layout and mounting holes. The HAT specification is backward compatible across Pi 2/3/4/5.
Do I need the EEPROM for my HAT to work?
No, the EEPROM is optional. Without it, you manually configure device tree overlays in config.txt. The EEPROM just automates this process.
Can I power the Pi from my HAT?
Yes, you can back-power the Pi through the 5V GPIO pins. Include a fuse and reverse polarity protection. Do not exceed 3A total for Pi 5.
Conclusion
Designing a Raspberry Pi HAT is an excellent PCB project that combines mechanical precision, digital design, and the satisfaction of creating a professional-grade add-on board. Start with the official dimensions, add your circuit, and follow the HAT specification for a board that fits perfectly and works reliably.
Find Raspberry Pi accessories and HAT references in our Waveshare collection.
Add comment