This type of Raspberry Pi add-on board uses only 5V power pins and the I2C bus pins (used for bidirectional data transfer with Raspberry PI), GPIO usage is minimal.
The I2C-HAT connector has 40 pins, only the I2C1 pins(SDA & SCL) and power pins(+5V & and GND) are used. This makes it possible for you to stack multiple I2C-HATs or even other types of add-on boards/HATs that use PIs GPIOs.
The I2C-HAT length is greater than the standard HAT, it extends over the Raspberry PI USB and Ethernet connectors, the mechanical dimensions are the same as PIs.
I2C baudrate and clock stretching
The recommended baudrate for the I2C-HATs is 100kbps, this is the default Raspberry PI I2C baudrate.
During I2C bus communication it’s possible that the I2C-HAT will stretch the clock until it finishes processing the current request. Clock stretching appears more often during the firmware update process. Make sure that the I2C bus master supports clock stretching if you plan to connect the I2C-HATs to other platforms than Raspberry PI .
IMPORTANT: The default clock stretching timeout value of the Raspberry PI is too small. For more details on how to setup the clock stretching timeout value see this post I2C clock stretching timeout on the Raspberry PI. If you install the raspihats package, the clock stretching timeout value will be automatically set as explained in the previously mentioned post.
The I2C-HAT has an address selector, you can select 16 different addresses. The selector controls the lower nibble(4 bits) of the address, the X part of the address(see table), the higher nibble is fixed, it’s value depends on the type of I2C-HAT(see table). Theoretically up to 200x I2C-HATs(max. 16x I2C-HATs of the same type) can be connected on the bus at the same time, provided you have the right power supply, the +5V rail should be able to supply the necessary current for your setup(PI and all HATs). You should check power consumption for all HATs you are planning to add to your setup.
Using I2C commands you can read the Board Name, Firmware Version and Status Word(32 bit) for every type of board.
In the next section you’ll find a short description of commands supported by different modules.
The Status LED has different blinking patterns used to indicate different states, usually the Status LED is labeled as LED1 on the PCB.
|75ms ON, 3s OFF||No Communication with RPi|
|75ms ON, 75 ms OFF, 75 ms ON, 3s OFF||Communicating with RPi|
The communication watchdog is used to detect a communication timeout, when a timeout occurs the Status LED pattern is changed and if the I2C-HAT has Digital Output Channels(Relays, Open Collectors, etc..) the Safety Value for the outputs is loaded.
Using I2C commands you can get/set the Communication Watchdog Period. The Period is stored in the on-board FLASH of the I2C-HAT.
Using I2C commands you can Get/Set the Digital Output Channels states, all at once or by specific channel. There are two concepts linked to the Digital Output Channels:
- PowerOn Value – loaded at power on, after reset
- Safety Value – loaded at communication timeout, signaled by the Communication Watchdog
The PowerOn and Safety Values are stored in the on-board FLASH of the I2C-HAT, so they’re available at next board power-up. Get/Set commands are available for both values
Using I2C commands you can get the Digital Input Channels states, all at once or by specific channel. Every Digital Input Channel has two Counters attached that count rising and falling edges. All counters can be GET/RESET using I2C commands.
Firmware Update is possible from RPi via I2C bus, check the I2C-HAT firmware update post.