If you build a custom board for the 40-pin header (sensor interface, relay board, power supply), follow Raspberry Pi's add-on rules. They prevent hardware damage and let the Pi configure your board automatically at boot.
Basic requirements (every board using pins beyond the original 26)
- ID_SC and ID_SD are reserved for the ID EEPROM. Don't use them for anything else, and leave them unconnected if you have no EEPROM.
- Back-powering: if your board feeds 5 V into the Pi's header, it must be safe when the Pi's own USB supply is also connected. The recommended protection is an ideal "safety" diode (see the design guide in the hats repo).
- Boot-time GPIO: protect against old firmware briefly driving GPIO 6, 14 or 16 at boot if your board also drives those pins.
What makes it a "HAT"
- Valid ID EEPROM (vendor info, GPIO map, device tree), full 40-way connector, the mechanical spec, at least 8 mm spacing.
- If it back-powers the Pi: at least 1.3 A continuous (2 A recommended).
A board with an EEPROM that doesn't meet the rest can't be called a HAT, but it can still offer GPIO autoconfiguration, which is strongly encouraged.
The ID EEPROM (HAT+): build and flash
The old raspberrypi/hats repo is deprecated. Use eeptools in raspberrypi/utils:
# build: copy eeprom_settings.txt to myhat_eeprom.txt and edit it, then
eepmake myhat_eeprom.txt myhat.eep
# on the Pi: disable the EEPROM's write protection (jumper or GPIO, see your schematic), then
sudo dtoverlay i2c-gpio i2c_gpio_sda=0 i2c_gpio_scl=1 bus=9
sudo apt install i2c-tools && i2cdetect -y 9 # standard HAT+ answers at 0x50
sudo ./eepflash.sh -w -t=24c32 -a=50 -f=myhat.eep
# re-enable write protection
| I2C address | Board type |
|---|---|
| 0x50 | standard HAT+ (or legacy HAT) |
| 0x51 | stackable HAT+ |
| 0x52 / 0x53 | stackable Power HAT+ (MODE0 / MODE1) |
eepflash.sh uses a software I2C bus (i2c-9) on GPIO 0/1, because the hardware I2C0 on those pins is shared with camera and display use.
Tips
- Make the EEPROM user-reflashable (write-protect jumper or GPIO), so you can fix a wrong device tree after shipping.
- If
eepmakegenerates a product UUID, copy it back into your settings file so every build keeps the same UUID. - For boards only using the first 26 pins: you can't call it a HAT, but still add the back-powering diode if it can power the Pi.