Monday, November 10, 2014

Connecting the Raspberry Pi to an 8 Channel Relay


Connecting the Raspberry Pi to an 8 Channel Relay


I bought an 8 channel relay module on Amazon (the one from Kootek, which appears to be a cheaper (in cost and quality?) version of the SainSmart device).

The relays operate off 5v, but the logic to control the relays is separate and can be worked by the 3.3v GPIOs.

I see quite a few posts that show a logic board between the Raspberry Pi and the Kootek 8 Channel DC 5V Relay Module. These do not appear to be needed as this logic for this is already on the relay board.

The relays do require 5 volts to operate, and this is provided by pin 2 (and 4) of the GPIO connector on the raspberry pi.  Connect Pin 2 from the Raspberry Pi to the pin on the far right, marked "JD-VCC". (If you have a jumper between VCC and JD-VCC, then remove the jumper) Note that there may not be enough power (amps) provided by the 5 volt supply to have all the relays operational at once. If you're running into issues, then power the relays off a separate 5v supply.

The trigger logic on the relay board is provided by the pins in the middle. The vcc one on the right needs to be connected to the 3.3v GPIO. This is pin 1.

The GPIOs that you want to use depends on what else you need. I'm using the ones on the edge of the board as they're easier to access, pins 26, 24, 22, 18 & 16. These are marked as GPIO 7, 8 25, 24 and 23 respectively. (or 10, 11, 6, 5  and 4 in WiringPi if you want to add to the confusion)

You also need to connect the ground pin. Note that there's a common ground, so you only need to connect one. If you're using a separate 5v supply, then you'll need to connect a separate ground, probably easiest to use the GND pin on the same block as the JD-VCC pin.

This looks like this:


I've shown the 5 volt power in red, the 3.3 volt in yellow, the ground in black and the GPIOs in green.
If you have a separate 5 volt supply, then use the same pins for the middle connector on the relay, but use the 5 volt as follows on the right hand connector