tl;dr — I'd like to connect this relay to the GPIO pins on my Raspberry Pi B+.

I'm looking into purchasing a solid-state relay for my Raspberry Pi. After a great deal of searching, I came across this 8-channel relay from Sainsmart:

enter image description here

However, I'm not exactly sure how to connect it to the Pi. This page provides a list of each of the pins. If I understand correctly, the GPIO pins provide 50 mA at 3.3V. There are also a couple of GPIO pins that provide 5V. According to the specifications for the relay, 3.3V should be enough to activate a channel.

Based on my extremely limited knowledge, I have come up with this wiring diagram:

enter image description here

Is this correct? Am I missing something? Any advice is greatly appreciated.

2 Answers 2


Your wiring diagram is correct, as (per the Sainsmart.com website you linked) the specs of the device are:

Input control signal voltage:

0V - 0.5V Low stage (SSR is OFF),
0.5V – 2.5V (unknown state).
2.5V - 20V High state (SSR is ON).

The Raspberry Pi uses 3V3 signals on its GPIO pins; a voltage level which is high enough to trigger the High State in the relay as per the specs. An Arduino (for which the same board is used) uses 5V signals on its GPIO pins and works equally fine with this board. The other circuitry on the board needs to be powered by a 5V source, for which you have correctly wired the board to the 5V power supply pin on the GPIO header.

The specs you quote are not completely correct, however. The GPIO header consists of power supply pins (1x 3V3 and 2x5V), several Ground pins, as well as GPIO pins. The GPIO pins (like GPIO17 you mention) are severely limited in the current they can supply (unlike the 5V pins which can supply at least 0.5A if not more depending on the rPi model). Each pin can output a maximum of 16mA (not 50mA as you mention), with a total maximum combined current across all pins of 50mA. This is enough to drive a few LEDs, but not much more. The pins are typically used for sending signals to other devices, and your relay is a perfect example.

As I mentioned, your circuit will work fine as you drew it (provided you supply a different power source to the relay terminals, the Sainsmart page says this about the Relay voltage and current it supports:

SSR Output (each channel):

 Load voltage range: 75 to 264V AC (50/60Hz).
 Load current: 0.1 to 2 AMP.

). It is common practice to put at least a resistor on the line between GPIO17 and the relay (1kOhm should be enough) to avoid a short circuit from frying your rPi via the GPIO pin. Also, if you want to be extremely safe, you can prevent an accidental miswiring from sending current to your output GPIO17 by wiring in a diode (make sure the polarity is right on the diode!).

Finally, since you are new to this, be extremely careful how you tap into the GPIO pins, especially the 5V pin. If you use proper female jumper wires there should be no issue, but if you decide to work with stripped wire on the GPIO end, you might end up inadvertently connecting the 5V pin with a GPIO pin, which leads to disaster (As I call it - "fried Pi"). Then - set your GPIO pin to be "output" (in whatever language/library you are using), and engage the builtin pull-down register (to make sure that when the signal "floats" it gets pulled down to 0V and doesn't accidentally trigger the relay).

Good luck!

PS: The video on the Sainsmart page is not much help, the only useful thing to observe is that in the demo they have the relay powered from a separate 5V supply instead of using the rPi's 5V GPIO pin. According to the specs, the board will only use 160mA, which is well below what the rPi can supply. So you're good either way. The Sainsmart page also has a Raspberry Pi "document" linked, but that page (https://github.com/fixedd/RPi_Relay_Interface#readme) has a disclaimer saying that its instructions are unnecessary for the Sainsmart module, as (quoting):

Note / Warning

This was formerly stated to be for the SainSmart relay modules, but it was later pointed out to me that these boards actually already have this logic built in to them.

  • You're welcome. The thing with electronics is that most of it is quite simple, once you understand the basic principles. I just wanted to make sure you had all you need to get started, and don't have to learn by frying a few Pi's :)
    – Phil B.
    Sep 18, 2015 at 3:54
  • Indeed, I'll definitely invest in proper jumpers to avoid shorting anything. Sep 18, 2015 at 3:59
  • 1
    Follow-up: your instructions worked perfectly and I was able to get some female-to-male jumpers that fit in the screw terminals on the relay. The remaining wiring was simple and I ended up writing a Go package to control the GPIO pins on the Pi. Jan 29, 2016 at 7:28
  • In your answer, you state that rPi can output a maximum of 50mA in total, and you proceed that the relay board uses 160mA, which is well below what the rPi can supply. This seems contradictory to me, please clarify.
    – Codor
    Nov 8, 2017 at 17:54
  • 1
    50mA is what the GPIO pins can supply. The 5V pin (also on the GPIO header, but strictly speaking not a GPIO pin but rather a passthrough of the supply power source) can handle larger loads, definitely more than the 160mA required by the relay board.
    – Phil B.
    Nov 9, 2017 at 11:52

The short answer is: yes. Based on the above wiring diagram when GPIO pin goes high the wires inserted into the screw terminal labeled 1 next to the relay will become connected. Conversely when GPIO pin goes low the 2 wires will become disconnected through the relay. If you were trying to power all of the relays from a single source you can daisy chain one screw terminal from each numbered bank together with a small jumper wire and provide the high voltage source to just one of the jumpered screw terminals. All of the other open screw terminals can then connect to your devices, lights, or whatever it is you are powering.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.