I’m writing this tutorial to highlight the advantages of using the DQ10rly I2C-HAT, a relay board specifically designed as an add-on for Raspberry Pi, rather than using a generic relay board.


  • easy install, just mount DQ10rly I2C-HAT on top of Raspberry Pi using the mounting kit, no wires required
  • stackable up to 16x, use the mounting kit extension to stack more DQ10rly's on the same Raspberry Pi, just like in this video
  • the only GPIOs that are used are the I2C bus pins(GPIO02 and GPIO03), all the other GPIOs are free to use for other purposes.

Materials needed:

  1. Raspberry Pi
  2. DQ10rly I2C-HAT
  3. mounting kit I2C-HAT

Raspberry Pi relay board

STEP1: Install relay board

Use the I2C-HAT mounting kit to install the DQ10rly I2C-HAT relay board on top of Raspberry Pi.

Raspberry Pi relay board mounted

STEP2: Enable I2C bus

Enable I2C bus on your Raspberry Pi using ‘raspi-config’ command. Open a terminal and type:

sudo raspi-config

Then go to Interfacing Options->Advanced Options->I2C and select YES when asked ‘Would you like the ARM I2C interface to be enabled?’ and also select YES when asked ‘Would you like the I2C kernel module to be enabled by default?’

STEP3: Install software packages

sudo apt-get install python-smbus

sudo apt-get install python-pip

sudo pip install raspihats

STEP4: Write a python control script

This is a simple script that will toggle relay channel 0 (2s on, 2s off):

from raspihats.i2c_hats import DQ10rly
from time import sleep
b = DQ10rly(0x50)
print("Use 'Ctrl+C' to stop program.")
    while True:
        b.dq.channels[0] = True
        b.dq.channels[0] = False
except KeyboardInterrupt:
    b.dq.channels[0] = False

STEP5: Control a led strip

Materials needed besides Raspberry Pi with relay board DQ10rly mounted on top:

  1. Led strip 12V/24W
  2. Power supply 12V/25W
  3. Power cable

Relay board led strip

danger-high-voltage Danger high voltage!!! Make sure you know what you are doing when connecting the power cable to the power supply.

DQ10rly can handle up to 5A of current per relay channel, in this case the led strip required current vis 24W/12V=2A. Be careful that your led strip current consumption does not surpass 5A and that your led strip power supply can handle it.

Connect led strip to relay channel 0:

Relay board led strip wiring diagram

Relay board leds strip wired