0

I am very new to all of this, so please excuse if this is a very basic question.

I am trying to power a tiny water pump with my raspberry pi. For that I need the 3.3V or 5V output, because the GPIO pins do not supply enough current.

In order to control it nonetheless, I decided to go with a 5V relay (this one).

I looked up tutorials online (e.g. this one) how to wire up the relay. The specify that the VCC should be connected to the 5V, which makes a lot of sense to me, because after all it is a 5V relay. The problem is, that if I wire it up like that, I cannot control the relay with a GPIO.HIGH command.

However, if I plug the VCC into the 3.3V output and change nothing else, everything works exactly how it is supposed to work.

So I was wondering if someone could explain to my why I am observing this behavior and if it is wrong or dangerous to power the relay with 3.3V like I am doing right now.

Cheers!

nickhir
  • 33
  • 4
  • Ah, yours is a common relay problem called "***Rpi GPIO High is not High enough for a 5V device (relay or otherwise.)***. You might like to read this TL;DR Q&A for more details. How to properly use a relay module with JD-VCC from Arduino/Raspberry? Asked 8 months ago Active 1 month ago Viewed 4k times https://electronics.stackexchange.com/questions/505318/how-to-properly-use-a-relay-module-with-jd-vcc-from-arduino-raspberry. – tlfong01 Feb 12 '21 at 13:13
  • One more thing: Your tutorial might be using a High level trigger relay, like mine: https://www.raspberrypi.org/forums/viewtopic.php?f=37&t=77158#p1323061. But your relay is very likely Low level trigger. The confusion is that High level trigger relay has not problem with Rpi, but ***Low level trigger relay has bad luck***. :) – tlfong01 Feb 12 '21 at 13:20
  • 1
    Does this answer your question? [Can you use a 5V Relay Module with the Pi?](https://raspberrypi.stackexchange.com/questions/118116/can-you-use-a-5v-relay-module-with-the-pi) – Milliways Jul 13 '21 at 07:20
  • Does this answer your question? [4 relay board weird behavior](https://raspberrypi.stackexchange.com/q/92299/33476) – Dmitry Grigoryev Jul 13 '21 at 07:41

2 Answers2

0

These (appalling designed) modules are controlled by a PNP transistor connected to 5V.

They can only be controlled by 5V - which requires an external transistor (which kind of negates the point of a module because you could just control the relay directly).
See Can you use a 5V Relay Module with the Pi?

Some claim they can be used with 3.3V - but the relay manufacturer claims 5V, so operation will be unreliable.

NOTE the Instructables link is WRONG and dangerous (these are often questionable and anyone can post misleading "instructions").

The reason it doesn't work is when GPIO is HIGH there is 5-3.3V i.e. 1.7V across the transistor B-E junction which is more than enough to turn the transistor on.

Even if it worked, putting 5V on a GPIO risks damaging the Pi. The substrate diodes provide some protection, but are not rated to carry any current and will eventually fail.

Milliways
  • 54,718
  • 26
  • 92
  • 182
  • Thanks for you answer. I did some more research and was wondering if you could quickly confirm if I understand everything correctly. If I buy a different Relay ([this](https://www.amazon.de/AZDelivery-4-Relais-Optokoppler-Low-Level-Trigger-Arduino/dp/B078Q8S9S9/ref=sr_1_6?__mk_de_DE=%C3%85M%C3%85%C5%BD%C3%95%C3%91&crid=28V14OO0QHMGX&dchild=1&keywords=relay%2Braspberry%2Bpi&qid=1613253774&sprefix=relay%2Brasp%2Caps%2C178&sr=8-6&th=1)) and I hook up the 5V from the RPi to the normal VCC, while also using the VCC - JD-VCC jumper. I should be able to control the relay with the 3.3V from the GPIO. – nickhir Feb 13 '21 at 22:52
  • @nickhir it is very difficult to comment on a device with no published circuit and minimal specifications and without more specific detail of what you are proposing (which should be edited into your Question) I can say no more than in the referenced Answer. If there is **any** path from 5V to GPIO you risk damaging the Pi. – Milliways Feb 13 '21 at 23:26
-1

This behavior is, in fact, a bit unusual, since most devices would recognize 3.3V as high, even if the power supply is at 5V. But it seems this is not the case here. That's not a big problem, though. If it works at 3.3V and the relais is (as I expect) properly separating the control side from the switch side you're all set.

PMF
  • 804
  • 4
  • 12
  • Its actually pretty common, the behavior comes from that circuitry that protects the relay, they usually use some sort of opto-isolator. And this circuit expects a HIGH signal to be close to VCC, so by lowering VCC to 3.3V, then an input of 3.3V is read as HIGH, whereas if VCC is 5V then 3.3V doesnt always read as HIGH. – Chad G Feb 12 '21 at 16:21
  • I don't know about different relays, but for most pieces, this is not the usual behavior. – PMF Feb 12 '21 at 18:41
  • Can you post a simple schematic as you have it wired and links to each of the hardware items. – Gil Mar 24 '22 at 00:50
  • @Gil There are readily available modules such as the one linked in the question from different vendors. They also come with the corresponding documentation on how to wire them and with example code. – PMF Mar 24 '22 at 06:17
  • This would be easier if you just used a Raspberry Pi relay hat. – NomadMaker Jul 21 '22 at 21:24
  • @NomadMaker You don't need a hat for that, there are also external modules that work just fine. They're connected using three wires (GND, VCC and enable) and contain all required parts (relais, protection diode, power transistor etc.) – PMF Jul 22 '22 at 07:45
  • @PMF Yes, it is possible, and maybe easy for you or I. The OP doesn't seem to be as familiar with a soldering iron. I just said that a hat is easier. – NomadMaker Jul 22 '22 at 12:20
  • @NomadMaker The ones the OP refers to (https://www.amazon.de/1-Kanal-Relais-Modul-Arduino-Raspberry/dp/B00UFW1YNK) do not need soldering. The cables to connect these modules with a Raspberry Pi (female - female in this case) are available from many vendors. – PMF Jul 22 '22 at 15:25