Raspberry Pi relay tutorial


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 on top of Raspberry Pi using the mounting kit, no wires required
  • stackable up to 16x, use the mounting extension kit to stack more DQ10rly’s on the same Raspberry Pi, like here
  • the only GPIOs that are used are the I2C bus pins, pin 3(GPIO02) and pin 5(GPIO03), all the other GPIOs are free to use for other purposes.

Materials needed besides Raspberry PI:

  1. DQ10rly I2C-HAT, a Raspberry Pi relay add-on board
  2. I2C-HAT mounting kit
raspberry relay board
raspberry relay board

STEP1: Install relay board

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

STEP2: Enable I2C bus

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

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

STEP4: Write python control script

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

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


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

Connecting the led strip to relay channel 0.

See it in action:

Leave a Reply

Your email address will not be published. Required fields are marked *