Relay module discussion notes

Active 2 months ago
Viewed 212 times

A am using working on a project that requires a camera analyzing some images and activating the appropriate GPIOs to control a relay board. I currently have a touchscreen display, a Raspberry Pi Cam attached to the Raspberry Pi. I am trying to connect a 16 channel relay module to control some motors. Here is the specific relay module I am using: https://www.amazon.com/SainSmart-101-70-103-16-Channel-Relay-Module/dp/B0057OC66U/ref=asc_df_B0057OC66U/?tag=hyprod-20&linkCode=df0&hvadid=311990496852&hvpos=1o1&hvnetw=g&hvrand=16991409045459790175&hvpone=&hvptwo=&hvqmt=&hvdev=c&hvdvcmdl=&hvlocint=&hvlocphy=9028086&hvtargid=pla-405660916688&psc=1 I looked at videos online about how to connect, however whenever I run it, nothing happens. The relay module has an external 12V power supply, which I connected. And I have connected all the GPIOs that I wanted to use from the Raspberry Pi to the relay board. IN addition, I connected the 5V and 3.3V connections to the 2 5V pins on the relay module (I used the 3.3 because the other 5V is being used to power the touchscreen display). I have checked all the voltages and everything seems fine. Whenever I run the following code, nothing seems to happen:

import RPi.GPIO as GPIO
import time


x = [27,28,29,32,31,36,33,38,35,40]

for y in x:
    GPIO.output(y, GPIO.HIGH)

Connections from Raspberry Pi

Connection to Relay

Overview Connections

migrated from superuser.com Jun 26 at 16:37

This question came from our site for computer enthusiasts and power users.

  • What is the point of connecting 3V3 to a 5V input? Why not split the 5V line? You need to add clear photos of your wiring if you want practical help. – joan Jun 26 at 16:45
  • I didnt have anything to split the 5V with… – Sajid Khan Jun 26 at 20:57
  • Perhaps it uses 5V logic. See if it switches if you connect 5V to one of the relay inputs. – joan Jun 26 at 21:38
  • This appears to use opto-isolation. There are many similar modules on the market and frankly they are unsuitable for the Pi. Get a module with logic inputs. – Milliways Jun 26 at 22:09

2 Answers


The relay module you linked (which has limited documentation) states:-

12V 16-Channel Relay interface board, and each one needs 15-20mA Driver Current

The Pi GPIO can (safely) sink up to 16mA – and if using all relays would overload an Arduino, and probably the Pi.

Of cause this is assuming the Pi could even drive the opto-isolator, but if this has a series LED and resistor is unlikely.

Powering from 5V is dangerous and is likely to blow up the Pi.

The comments on the Amazon site indicate it us unsuitable for use with the Pi.

As an aside there is absolutely NO POINT is using an opto-isolator with a relay! Any additional isolation they claim to supply is illusory if there is ANYcommon connection between the two. Opto-isolators have a low current transfer ratio – which just makes it harder for the Pi to drive.

There are a number of (poorly-designed) relay boards on the market – they MAY work with an Arduino, but are unsuitable for the Pi. (There are quite a few posts on this site discussing these.)

There ARE modules (without opto-isolators) designed to be driven by 3.3V logic levels which are suitable.

You could drive this from the Pi using a transistor (if you haven’t already blown the Pi).



  1. relay module has 12V power supply, …
  2. have connected all the Rpi GPIOs relay board, …
  3. connected 5V and 3.3V connections to the two 5V pins on the relay module (5V is being used to power the touchscreen display) , …
  4. Run code, nothing happen, …


It is not clear why you connect 3V3 power to 5V. And it is not clear if your 12V power relay accepts Rpi GPIO 3V3 signals.

The most newbie proof way is to use 3V3 relays which are a bit expensive (see Appendix A below).

Cheapy relays are mostly 5V powered, but only those High level trigger types are almost guaranteed to work for Rpi.

Almost half of those Low level triggered relay work for Arduino, but NOT work for Rpi (See Appendix B for get around).

And avoid using 12V powered relays, because newbies always connect the wrong wires to Rpi GPIO.


Appendix A – Rpi Compatible 3V Relays (US$20 ~ US$30)

PiFace Raspberry Pi Relay Board – £27

WaveShare Raspberry Pi Relay Board – $19

SeeedStudio Raspberry Pi Relay Board – $25

seeeduino relay

Amazon WaveShare Raspberry Pi Compatible Relay Module with photocoupler – XYG Study US$24

Amazon Electronics-Salon RPi Compatible (Panasonic) Relay Module – Electronics-Salon UUS$17

Using the Seeed Studio Raspberry Pi Relay Board – JM Wargo 2017feb14

Appendix B – Get Around for Arduino Compatible Low Trigger Relay not Working for Rpi

Get Around for Arduino Compatible Low Trigger Relay not Working for Rpi

Appendix C – Forbes Recommended, Optoisolated, Low Level Trigger 5V Relay (US$7)

5V Relay for Raspberry Pi Home Automation US$7 – Forbes Finds 2018jul12

Forbes Recommended Amazon Rpi Compatible 5V Relay Module – US$7

Errata – The product spec says each channel needs 15mA ~ 20mA to drive.

THIS IS PLAIN WRONG! I measured a couple of similar relay modules and found each input end takes only 3mA to 5mA. In other words, the current sinking requirement is OK for Rpi GPIO pins.

Opto Isolation Consideration

This Forbes relay module has opto isolation, therefore the risk of resultant back EMF, EMI transients flying back to Rpi is much reduced, so your Rpi can live longer! You can even reduce back EMI / EMI by using “total optical isolation” (Must/need JD-Vcc jumper, see references and appendices for more details)

Appendix D – Cheapy Single Channel 5V Relay Modules for Poor Hobbyists (US$1)

For hobbyists and newbies, I would like to recommend the dirt cheap single channel, no optoisolation, high level trigger modules. Just now I googled “5v relay module raspberry pi” and found 200+ results.

Google search results for “5v relay module raspberry pi”

I found the Keyes KY019 relay module which I have tested OK for Rpi.

Keyes KY019 Single Channel 5V High Level Trigger Relay US$1 each

ky019 module

Categories: Uncategorized

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.

%d bloggers like this: