Relay

Rpi GPIO not high enough to switch off low trigger relay

1
1

Devices I am using are:

1) Songle 2 channel relay module – https://www.electronicscomp.com/2-channel-5v-relay-module-with-optocoupler?gclid=CjwKCAjwvuzkBRAhEiwA9E3FUnbadf71q6h2pX_VsmrUK6x0c9dHQm9aZ0EjEIRIoKsbmvFoRhY96xoCbcUQAvD_BwE

2) Breadboard power supply module – https://robu.in/product/mb102-breadboard-power-supply-module-3-3v5v-arduino-solderless-bread-board/?gclid=CjwKCAjwvuzkBRAhEiwA9E3FUv8xyHVyNeRe8mcrdalrsXgTt5vg0q4JGdTITGhJbK6W5PAdKWy4XRoC64YQAvD_BwE

Connections which I have done are :-

Do keep in mind that I have used the Raspberry Pi for only GPIO pins connection to IN1 and IN2 of the relay module and power supply to the relay module is from that breadboard power supply module I have put the link to above.

1) JD-VCC of the relay module to 5V of the power supply module.

2) VCC of the relay module to 3.3V of the power supply module.

3) GND of the relay module to the ground of the power supply module.

4) IN1 and IN2 of the relay module to Raspberry Pi’s GPIO 13 and GPIO 6 pins. (No power supply is there from the Raspberry Pi).

only the relay status led is getting blinking, but not the relay switching sound is not being heard.

 New contributor
  • Sure I will edit my question. – Aditya Raghu 2 days ago
  • Connect 3v3 from PI to VCC on 4 pin connector next to IN2, connect iN1 and IN2 to pi, connect a SEPARATE 12V supply to JDVCC and GND on the three pin connector – that is all you need – do not connect GND on 4 pin connector, when opto-isolated, you actually don’t need it. – Jaromanda X 2 days ago
  • I actually have a relay with a 5V operating voltage, not a 12V. I put up the wrong link by mistake. I changed it just now. The thing is I don’t want to give any power supply from the raspberry pi, I want to give everything from the breadboard power supply itself. And I have tried what you said also many times actually, but I am getting the same result. – Aditya Raghu 2 days ago
  • you definitely need vcc (next to IN2) connected to pi 3v3 … because that vcc forms a circuit, through an opto-isolater, and back through IN1/IN2 to control the relay … edit (removed rant about 5v, since you are not putting 5v there) – Jaromanda X 2 days ago
  • also GND of the relay module to the ground of the power supply module which GND? the one on the JD-VCC headers (correct) or the IN1/IN2 headers (incorrect, see my comment do not connect GND on the 4 pin connector – Jaromanda X 2 days ago
  • Sure then, I will try it out again and let you know asap. – Aditya Raghu 2 days ago
  • You said you tried before, so don’t – Jaromanda X 2 days ago
  • So what else shall I do? – Aditya Raghu 2 days ago
  • I was kidding, of course do exactly what I suggested, and see if it works – Jaromanda X 2 days ago
  • I am 90% sure that yours is a “low logic level trigger” module which Rpi cannot directly control. – tlfong01 2 days ago   
  • @tlfong01 GPIO.setmode(GPIO.BCM) GPIO.setup(4,GPIO.OUT) GPIO.output(4,GPIO.LOW) time.sleep(15) GPIO.output(4,GPIO.HIGH) GPIO.cleanup() this is the code which we have used to trigger the relay using raspberry pi,we have connected 5v source to jd-vcc and 3.3v to vcc of the 4 pin header.Is there any harm in using the above method in the functioning of the relay. – Aditya Raghu 2 days ago
  • My English is bad. My brain has been squeezed with too many foreign language stuff, so short term memory left is 5 times smaller than average. As I said earlier, I will draw you a picture later to confirm your complicated JD-Vcc wring, and also confirm your code. I appreciate your patience. – tlfong01 yesterday  
  • @Aditya Raghu: Your program seems one off. You may read my demo program in the old post referred below. I am using a repeat loop to switch on and off the relay, so I can hear a click click song, and also use a oscilloscope to watch any noise or EMI. – tlfong01 39 mins ago   Edit   

2 Answers

2

The specification of the relay board you linked to says it requires 12V to operate it.

  • Sorry, I just put up the wrong link. My relay needs 5V to get activated. The thing is when I connect the VCC and JD-VCC to the arduino, my relay is working fine but not from the breadboard power supply module. – Aditya Raghu 2 days ago

0

I am 90% sure that your module cannot be directly controlled by Rpi. I will first point out the problems, then suggest ways to get around.

enter image description here

I will search my junk box to find a relay similar, and do some experiments to verify my guesses are correct.

Luckily I found a similarly looking guy. First thing first is to check out if it is (1) low logic level activate/triggerable, and (2)5V Logic compatible.

Me no English, so I selfie!

To show module (1) low activate, (2) 5V logic

Now that I know the relay module switches on when In1 is Ground, and off when In1 is 5V, I move on to test (a) how high, say, 3V or 4V can still turn it off, and (b) how low, say, if 1V or 2V can still turn it off.

There you go, selfies again.

Finding relay activate/deactivate signal voltages

Earlier I though my module similar to the OP is not Rpi compatible either. But I surprising found that its trigger points are approximately 1.8V- and 2.4V+. Since Rpi’s low level is < 1V, and high level > 2.8V, therefore Rpi has no problem switching it on/off. (Arduino high/low are approximately < 1V and > 4V, so also has no problem.)

So now I still need an example similar to the one OP has, to explain why Rpi’s low signal is OK to switch it on, but Rpi’s high signal is not high enough to to switch it off (without fiddling with the JD-Vcc jumper, which most newbies never heard of!). I searched my junk box again, and did similar engineering experimentation with the results below.

enter image description here

Now the time has come for me to answer the OP’s question about using the JD-Vcc way of supplying power to the relay, and an example of Rpi Python code to control it.

I am using a relay recommended by Forbes. You might like to read the following Forbes article before I explain. But the picture first.

Everything You Need To Set Up Raspberry Pi Home Automation – Don Reisinger, Forbes(recommending an optoisolated, low level trigger relay) https://www.forbes.com/sites/forbes-finds/2018/07/12/everything-you-need-to-set-up-raspberry-pi-home-automation/#7c65bdb04cdb

Forbes low trig opto relay

Will this code harm rpi, and how does JD-Vcc work?

GPIO.setmode(GPIO.BCM) … code used to trigger relay using raspberry pi, connected 5v source to jd-vcc and 3.3v to vcc of header. Is there any harm in using the above …

connected 3.3V of relay to 3.3V of the RPi. JD-VCC to 5V of the power supply. ground of relay to ground of power supply. Now it’s working. The question now is, why isn’t the relay working when I connect the VCC of the relay to 3.3V of the power supply. …

To answer the above questions, we need first to see how the photocoupler works. Here is the picture.

EL87C and EL354 Photocoupler summary notes

Now that we know the specification of the photocoupler, we can do some quick and dirty calculations, to make sure that the relay will not harm you rpi GPIO.

Not using Rpi’s 40 pin connector’s 5V, 3V3 power pins to power relay

Just now I read your question again and I gave it an up vote, because of the more than ten user questions I read so far about this FAQ topic, yours has the most detailed description of the frequent newbie problem of Rpi not being able to turn off a low level trigger relay which Arduino has no problem, because the relay was designed for Ardunio, perhaps before Rpi was born.

I particularly appreciate your specifically pointing out that you are using the external power supply unit, even with a web link. This is a very important guideline for newbies often connecting the wrong wires by mistake. Actually I have been using Rpi for 5 years, and I NEVER USED the RPI’s 40pin connector power pins to power any external device.

Low Trig Opto EL817C 5V Relay Rpi GPIO Input Current Requirement Calculation

enter image description here

Working backwards, Ic needs only 1mA. Working forward, If 5mA would generate 10mA Ic, fully saturate photo transistor. Conclusion – Rpi GPIO Low need only 5mA to fully saturated photo transistor.

The question is Rpi GPIO High too High to cut off photo transistor?

/ to continue, …

  • thank you so much for your help. According to the above circuit diagram of yours, I connected VCC of my relay module to 3.3V of the RPi and the JD-VCC to 5V of the breadboard power supply. And I connected the IN1 and IN2 pins of the relay to GPIO pins. Now it’s working perfectly. But just one more thing, may I know why when I connect both the VCC and JD-VCC of the relay to 3.3V and 5V of the breadboard power supply module, it’s not working? Why only when I connect it to two separate sources it works? May I know the reason why? – Aditya Raghu yesterday
  • Just a quick reply. Perhaps no common ground, or no ground for Rpi sink driver to return current. I need to look at the schematic again later. Perhaps you can also check the current loop and common ground thing. This is also a FAQ and common newbie trap. Have a nice DIY weekend. – tlfong01 20 hours ago   
  • Before I make a long reply, you might like to skim my other long answer in the following post. Take note of the activate current of 70mA of the relay switch. I will use that to calculate the safe current of the Rpi sink driver. The manual testing of using a jumper wire to test an opto low trig relay is also useful. I will also extend that to explain the separate JDvcc and Vcc separate power supply and no command ground problem. raspberrypi.stackexchange.com/questions/27928/… – tlfong01 2 hours ago   
  • I skimmed my old post above and found that I mentioned the following: FAQ1 – How to power Rpi and relay module and tie grounds together, FAQ2 – How to avoid floating input problem. These are actually old answers to your new questions here. But I forgot where I put the answers which are scattered all over the place. I need to google search my own rubbish, tidy them up and perhaps post it here. – tlfong01 2 hours ago    

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

.END

Categories: Relay

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

%d bloggers like this: