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 GPIO.setmode(GPIO.BCM) GPIO.serwarnings(False) x = [27,28,29,32,31,36,33,38,35,40] for y in x: GPIO.setup(y,GPIO.OUT) GPIO.output(y, GPIO.HIGH) time.sleep(0.5) GPIO.output(y,GPIO.LOW) GPIO.cleanup()
migrated from superuser.com Jun 26 at 16:37
This question came from our site for computer enthusiasts and power users.
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).
- relay module has 12V power supply, …
- have connected all the Rpi GPIOs relay board, …
- connected 5V and 3.3V connections to the two 5V pins on the relay module (5V is being used to power the touchscreen display) , …
- 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 (Very Expensive!)
Appendix B – Get Around for Arduino Compatible Low Trigger Relay not Working for Rpi
Appendix C – Rpi Compatible, Optoisolated, Low Level Trigger 5V Relay Recommended by Forbes (US$7 Only)
Appendix D – Cheapest US$1 Single Channel 5V Relay Modules for Poor Hobbyists
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.
I found the Keyes KY019 relay module which I have tested OK for Rpi.