This is part one of a two part guide. When I get a free moment I will show you how to harness the output in another guide.

Here is a sample guide with how I set up a SainSmart Relay powered by a Raspberry Pi. There seems to be a lot of confusion about how to hook these up and how to wire them to a device.

 

Disclaimer: I am not an electrical engineer, I am a programmer. Proceed at your own risk.

 

Lets first start out with the pins of the SainSmart Board. There is a jumper that has a VCC and a JD-VCC pin on it. I have the jumper in place. Removing this allows you to power the relays on a separate power supply and drive them with the Pi. The other 6 pins are for the VCC (power from the Pi), GND, and the Input Pins (IN1 – IN4) there is one for each relay.

SainSmart Pins

SainSmart Pins

Now before I get into how I wired the relay to my Pi. I wanted to say there is a lot of information about connecting the GPIO ports directly to the board being harmful to the board. so I pulled out the old voltmeter to test. Click the image to enlarge. The results show that the average output from the IN pins is 3.0 volts. This would be just fine and not cause any damage to the Raspberry Pi’s GPIO.

Voltmeter voltage IN1 to GND

Voltmeter voltage IN1 to GND

Now to take it a bit further this safe voltage is actually caused by the LED that is inline with each of the relays. I tested the LED with a diode tester and got the following results. The forward voltage is about 1.7 volts. This means that at max we would have 5.0 v input – 1.72 voltage drop = 3.3 volts. Both of these tests seem to show that directly wiring the GPIO to the relay should be just fine. That all said I would recommend putting a resistor between the GPIO and relay IN might be a safe idea to make sure we are keeping the current to a minimum just in-case.

SainSmart LED Forward Voltage

SainSmart LED Forward Voltage

Now let take a look at wiring. (Click to Enlarge)

SainSmart Relay Input Wiring

SainSmart Relay Input Wiring

  • Relay Board Jumper
    • Connected
  • Red Wire
    • Relay Board: VCC
    • Pi Pin: 4
    • Pi Board: 5volt
  • Black Wire
    • Relay Board: GND
    • Pi Pin: 6
    • Pi Board: GND
  • Orange Wire
    • Relay Board: IN1
    • Pi Pin: 11
    • Pi Board: GPIO 17
  • Yellow Wire
    • Relay Board: IN2
    • Pi Pin: 18
    • Pi Board: GPIO 18
  • Blue Wire
    • Relay Board: IN3
    • Pi Pin: 13
    • Pi Board: GPIO 27
  • Green Wire
    • Relay Board: IN4
    • Pi Pin: 15
    • Pi Board: GPIO 22

Turning the GPIO to low activates the relay and turns on normally closed circuit. Turning it to HIGH activates the normally open circuit. Below is an image of what I mean by this. Out of the three terminals for each relay the middle is the common. The left is the normally closed and the right is the normally open. If you want a circuit that you must turn on the relays to activate you would use the two left terminals.

 

SainSmart Relay Terminals

SainSmart Relay Terminals