Page 1 of 1
Wiring 4 channel relay to RPI2b doesn't work
Posted: Thu Jun 08, 2017 4:07 am
by alsaine
Hi, I have tried to follow this guide
https://www.youtube.com/watch?v=oaf_zQcrg7g
and I have wired it as shown below
however it doesn't light up and doesn't seem to work at all.
Any tips?
Re: Wiring 4 channel relay to RPI2b doesn't work
Posted: Thu Jun 08, 2017 11:13 am
by Burngate
You'll see there's a jumper installed, connecting Vcc to JDVcc
One of those supplies is for the relay; the other is for the opto-isolator input
The relay requires 5v, but the GPIO cannot supply 5v to switch the opto off, so you need to remove the jumper and supply 3v3 to the other supply.
Re: Wiring 4 channel relay to RPI2b doesn't work
Posted: Thu Jun 08, 2017 11:44 am
by alsaine
Burngate wrote:You'll see there's a jumper installed, connecting Vcc to JDVcc
One of those supplies is for the relay; the other is for the opto-isolator input
The relay requires 5v, but the GPIO cannot supply 5v to switch the opto off, so you need to remove the jumper and supply 3v3 to the other supply.
Hi Burngate,
Thanks for your quick reply. Can you clarify some things?
Is ONLY 3v3 required, or is ground required on the right side of the relay too? I'll be trying this either way but just thought I may as well ask.
And why doesn't my relay work in a similar way to the one in the example video-- which has the jumper installed and no additional power supply?
Re: Wiring 4 channel relay to RPI2b doesn't work
Posted: Thu Jun 08, 2017 12:09 pm
by SurferTim
That board should work ok with a 5v supply to the relay board. The combination of the opto-isolator led and the DS1-DS4 diodes should protect the RPi inputs from overvoltage.
Bear in mind that LOW is on and HIGH is off.
Re: Wiring 4 channel relay to RPI2b doesn't work
Posted: Thu Jun 08, 2017 12:10 pm
by alsaine
Hi,
Making the suggested changes and running commands like
import RPI.GPIO as GPIO
GPIO.setmode(GPIO.BCM)
GPIO.setup(2, GPIO.OUT)
GPIO.output(2, GPIO.LOW)
GPIO.output(2, GPIO.HIGH)
does nothing. No clicking, no LEDs, nothing.
Please note that these commands do nothing even in my original wiring.
Re: Wiring 4 channel relay to RPI2b doesn't work
Posted: Thu Jun 08, 2017 12:15 pm
by SurferTim
Try connecting the digital control pin to GND on the RPi. Do you get a response from the relay board?
Re: Wiring 4 channel relay to RPI2b doesn't work
Posted: Thu Jun 08, 2017 12:23 pm
by alsaine
SurferTim wrote:Try connecting the digital control pin to GND on the RPi. Do you get a response from the relay board?
Hi Tim,
Appreciate your reply. Good thinking-- connecting it to ground works! It functions as might be expected-- both LED toggles, and the noise of the switch activating/deactivating can be heard clearly. Does that mean there is an issue on the software end?
I should note that when I run through the above commands in an interactive python shell, I do get as follows on the first time through:
>>> GPIO.setup(2, GPIO.OUT)
__main__:1: RuntimeWarning: This channel is already in use, continuing anyway. Use GPIO.setwarnings(False) to disable warnings.
Not sure if that matters.
Re: Wiring 4 channel relay to RPI2b doesn't work
Posted: Thu Jun 08, 2017 12:26 pm
by SurferTim
If it works with the digital control pin connected to GND, then there are at least two possibilities for malfunction.
1) Your control wire is connected to the wrong RPi pin
or
2) Your code isn't working as you expect.
edit: Have you tried using a different GPIO pin?
Re: Wiring 4 channel relay to RPI2b doesn't work
Posted: Thu Jun 08, 2017 1:01 pm
by alsaine
SurferTim wrote:If it works with the digital control pin connected to GND, then there are at least two possibilities for malfunction.
1) Your control wire is connected to the wrong RPi pin
or
2) Your code isn't working as you expect.
edit: Have you tried using a different GPIO pin?
Thanks Tim,
Got it working with your suggestions, seems like my GPIO pin 2 is bugged or broken. Strange. Again, really appreciate your help.
Re: Wiring 4 channel relay to RPI2b doesn't work
Posted: Thu Jun 08, 2017 1:04 pm
by SurferTim
If you have used I2C on that RPi, that could cause a conflict on that pin.
Re: Wiring 4 channel relay to RPI2b doesn't work
Posted: Thu Jun 08, 2017 1:07 pm
by Ernst
I would suggest to use 17 (Pin 11) instead of 2 (Pin 3) because the intended use for i2c (2=SDA.1 and 3=SCL.1)
If you have enabled i2c (in raspi-config or /boot/config.txt) this could interfere with your usage.
Re: Wiring 4 channel relay to RPI2b doesn't work
Posted: Thu Jun 08, 2017 1:10 pm
by alsaine
Ah!
I have enabled I2C, although I am no longer using it. I will switch to Pin/GPIO 17 as suggested.