1

I have a developer background missing the electronics background. I read some threads with great interest:

  1. Using single 5V relay (jqc-3ff-s-z) - safety advice required and
  2. 5V relay (jqc-3ff-s-z)

I need to drive three relays and because I already destroyed a RPi by using too much power I was thinking to power the relay-modules by an external 5v psu Psu (Vcc), RPi and relay's ground pins all connected together. The Relay's IN-pin is directly connected to different GPIO pins (cf. image). This should be possible according one of the answers above.

Now I see the relay is always on (green led is always burning) even if I toggle the GPIO value Low <-> High. However, I see some difference in current consumption

  1. If the GPIO value is low, only 136uA is consumed.
  2. If the GPIO value is high, 4mA is consumed (I think this is safe, just below 5mA).

But, again, in both cases the relay stays ON and is not toggling when I expected it.
Can someone give me some advice/tips to 'debug' this problem? Many Thanks.

set-up

EDIT: V2

Thank you all in advance for the extensive information and answers. I try to process them, not easy. To @Joan: I can't find a schema right away. But it is the relaymodule that is visualized in the next question, exact the same (Using single 5V relay (jqc-3ff-s-z) - safety advice required).

Furthermore, I understand that the voltage is not high enough. That seems already logical to me. It also reminds me that I tried the sparkfun logical converter (https://learn.sparkfun.com/tutorials/bi-directional-logic-level-converter-hookup-guide/all) Also without result:

  • GPIO off: gave a stable relay off situation
  • GPIO on: caused the relays to vibrate (on-off and vice versa)
    cf. Fritzing scheme. (Sorry for my incompetence to provide a detailed scheme) So if anyone can help met through this set-up It's fine for me too. Already thanks a lot!

Set-up with level converter

Edit - V3 @joan,
as asked I added some pictures of the module. Hopefully you can help me out with this. Thanks already.

Module 1/3

Module 2/3

Module 3/3

Module backside

GuyH
  • 21
  • 1
  • 5

4 Answers4

2

You've made a mistake, I'm afraid. You seem to be attempting to switch the relay coil with a GPIO pin. Unless your relay module is designed to use a 3.3V input you are at risk of breaking another RPi.

GPIO pins are for 3.3V - and ONLY 3.3V

In addition, the GPIO pins are delicate little flowers; they won't source (or sink) much current, and they don't tolerate voltages over their rated limit well at all.

Here's the rest of my answer:

  1. Get the detailed specs for your relay module (per @joan cmt); edit your question to add the details, or better still link to them so no details are left out.

  2. For clarity that will help YOU get a better answer: Create an actual schematic instead of the fritzing stuff (here's how)

  3. There are tons of how do I drive a relay question on this site. Some include schematics. Maybe read them? (1, 2, 3, and if you need more: 1,304 other results)


EDIT:

The correct answer to the OP's question appears to be the 2nd schematic in Ghanima's answer. I say "appears" only because this being a correct answer depends upon the accuracy/applicability of the analysis done by the author of this article.

Perhaps in a larger sense, another answer to this question, and hundreds of others seen here in RPi SE, is to follow this simple rule:

DO NOT BUY ELECTRONIC PARTS FROM FLY-BY-NIGHT SELLERS WHO DO NOT FURNISH A DETAILED SET OF SPECIFICATIONS: "NO SPEC SHEET - NO SALE!"

This question could have been resolved with a fraction of the time & effort expended by all involved parties if a "spec sheet" had been provided by the vendor. I recently posted a more pointed version of this view with a few more details & advice on identifying quality suppliers.

Seamus
  • 23,558
  • 5
  • 42
  • 83
2

Unfortunately there are many different relay boards out there using this particular relay but that might feature different driving electronics. So it's difficult to give a definitive answer. There are however some indications that this excellent arcticle /1/ covers this board and the problems the OP describes.

enter image description here (Image source: /1/)

I leave it to the OP to confirm that this circuit matches the board but from the pictures provided and the description of its behaviour this seems to fit.

The picture of the PCB shows that the transistor is on the high-side of the load - the relay's coil. So if this transistor is a Bipolar Junction Transistor it would be PNP. Per the OP's measurement "If the GPIO value is high, 4mA is consumed" it's safe to assume that the transistor is bipolar and not FET. This is backed up by the OP confirming "2TY" as the marking of the transistor. So according to /1/ this has the drawback:

The signal voltage needs to be near the Vcc to shut off the relay. The Vbe saturation voltage is -1.2Volt. So if fed with 5 Volt, anything lower than 5-1.2=3.8V will keep the transistor in saturation.That means that you cannot feed the circuit with 5Volt and use a 3.3 Volt microprocessor to give the input signal, because a HIGH of 3.3 Volt is not high enough to close the PNP transistor.

/1/ provides a simple solution to overcome this issue. This however will draw an additional current from the Pi's voltage regulator and might thus not work if a larger number of relais needs to be driven (side note: here and here and here it is indicated that up to 800 mA could be sourced from the 3.3V rail, so quite a number of such relay modules could be used):

That means that if you want to use it on a raspberry Pi or an ESP8266, you will have to use the 3.3 Volt pin to feed the relay. The relay is a 5 Volt type, but it will work on 3.3 Volt but at 70 ohms it draws an extra 47mA from the 3v3 LDO.

The above does not explain why it also fails using logic level converters (as the V2 edit of the question indicates).

/1/ recommends to use an additional transistor to drive the relay board from 3.3V GPIO pins. Note that this inverts the logic again.

enter image description here (Image source: /1/)

Ghanima
  • 15,958
  • 17
  • 65
  • 125
1

From the rather unclear photos you have posted the device does not have an opto-isolator but a transistor.

It is unclear why it doesn't work, however there is another type of poor module, triggered by a low level, with a PNP transistor which is not controllable from 3.3V. (This saved the manufacturer some fraction of a cent.)

Without a circuit it is not possible to be sure. It would be quite simple to trace the circuit yourself to determine what it contains.

NOTE I hope you are not planning to put mains voltage on the modules. From the detritus visible on the boards there would be inadequate isolation, even with the cutout. This is probably a cheap rip-off of some other device, as the condition of the board indicates poor manufacture.

Milliways
  • 62,573
  • 32
  • 113
  • 225
0

@Ghanima: a final question: if I duplicate the workable circuit to drive multiple relays, is it allowed to share Ground (X1-1) and 5V (X1-2) as depicted in my drawing.
Or should it be different separate circuits ?, however Ground and 5V will be shared via the PSU connectors then...
PS. what is OP stands for? enter image description here

GuyH
  • 21
  • 1
  • 5