0

Is "normally" open relay opened on 0V or 5V?

Here it is written that yes. But here it is written that no.

What is the truth?

Experimentally I see, that my relay module LED lights ON and "normally open" pin closes on OV on GPIO.

That would mean that "normal" is 5V and I would just flip contacts, but...

The problem is that I want it be "normal" common sense, i.e. it should be the state when Raspi is just turned on, which is not true. When I turn on my Raspi, my NO relay is open. When I set

GPIO.setup(pin, GPIO.OUT)

it turns 0V and closes. So I can't access relay without triggering it.

Is it possible to overcome?


Here is my module:

enter image description here


I am connecting VCC of module to 5V pin of Raspi, GND to GND, and IN to GPIOs.

Whatever "normal" is, why is it change on

GPIO.setup(pin, GPIO.OUT)

? Shouldn't it be and stay in "normal" before and after this instruction?

Dims
  • 129
  • 6
  • What relay? How is it connected? See [Can you use a 5V Relay Module with the Pi?](https://raspberrypi.stackexchange.com/a/118117/8697) – Milliways May 01 '22 at 23:41
  • both your links point to relay modules, not to relays ... a relay is the blue block component on the relay module PCB ... the state of the relay in the relay module is dependent on the circuitry that drives the relay – jsotola May 02 '22 at 00:22
  • My short answer is ***yes and no, it depends***. Let me know which relay module are you using, high or low trig etc: https://electronics.stackexchange.com/questions/505318/how-to-properly-use-a-relay-module-with-jd-vcc-from-arduino-raspberry – tlfong01 May 02 '22 at 02:02
  • The Pi's GPIO are 3V3, NOT 5V. – joan May 02 '22 at 07:35
  • @jsotola sorry, of course it's relay module, see photo – Dims May 02 '22 at 10:45
  • @Milliways see photo; I have connected VCC to 5V, GND to GND and INs to GPIOs, directly – Dims May 02 '22 at 10:47
  • @joan what are implications? – Dims May 02 '22 at 10:47
  • @tlfong01 see the picture pls – Dims May 02 '22 at 10:48
  • The photo is meaningless particularly as you don't show connections to Pi - post REAL data i.e. link to module and text describing connections, but if you are using one of these dodgy modules without additional circuitry it won't work and may have damaged your Pi. – Milliways May 02 '22 at 12:06
  • 1
    PS I HOPE the connections are NOT to mains power as this would violate all safety standards and you are risking electrocution. Even in an approved enclosure the shown wiring would fail safety rules. – Milliways May 02 '22 at 12:09
  • @Dims: (1) There are two kinds of relay (modules): (a) High level (3V3) trigger, (b) Low level (0V) trigger. (2) There are two kinds of terminals you can use (a) normally open, (b) normally closed. In other words, 4 combinations: (i) HT NO, (ii) HT NC, (iii) LT NO, (iv) LT NC. (3) For 110/220VAC circuits, to play safe, you usually connect L wire to COM, and NO to your lamp etc. (4) For low voltages, say less than 24VDC, you can try different wiring combinations to learn the principles. – tlfong01 May 02 '22 at 13:40
  • @tlfong01 whatever "normal" is, why is it change on `GPIO.setup(pin, GPIO.OUT)`? Shouldn't it be and stay in "normal" before and after this instruction? – Dims May 02 '22 at 15:11
  • @Milliways why would it damage my Pi I don't understand? – Dims May 02 '22 at 15:17
  • What load are you switching with those relays? If it's AC mains then it is **NOT SAFE**. You can't have twisted neutral wires, like that. You can't have exposed copper, like that. The better way to run a Raspberry to switch mains is to switch 24V with the relay on the RPi. Then switch the load with a mains relay, mains SSR or mains contactor (from the 24V circuit) closer to the load. – Dougie May 02 '22 at 15:28
  • @Dougie what do you mean "exposed copper"? You mean somebody can touch in and get shocked? It's for testing purposes, so don't worry – Dims May 02 '22 at 15:54
  • @dims in the photo just below "Here is my module:" there are switched cables that have exposed copper, they aren't insulated. Curious fingers can get a shock (or will trip your RCD/GFCI) if they touch those exposed wires. **IT IS NOT SAFE**. If you aren't competent to wire the relays you **MUST** get what you're doing checked by a qualified electrician. Mains at 110V can kill. Mains at 230V WILL kill. – Dougie May 02 '22 at 16:03
  • @Dougie I am using additional contactors to control high voltage and entire assembly will be inside a case. It is test assembly – Dims May 02 '22 at 19:04
  • You're still crap at wiring screw down terminals. Make your joints tidily and they won't fail so quickly. Don't stuff two wires in one terminal, use a Wago if you need to connect two wires together. – Dougie May 02 '22 at 20:02
  • I am doing connect change often until I understand how it works – Dims May 02 '22 at 20:34

1 Answers1

2

"Normally open" contacts are open when there's 0V on the relay coil. Depending on the circuit of the module, that could correspond to 0V or 5V on the digital input which you connect to the Pi. Apparently, that's 5V for your module, or, more precisely, 3.3V since that's the maximum allowed voltage for the Pi GPIO.

Mechanical relays are slow, so if you run

GPIO.setup(pin, GPIO.OUT)
GPIO.output(pin, 1)

it will not have enough time to toggle.

Dmitry Grigoryev
  • 26,688
  • 4
  • 44
  • 133
  • 1
    Nice workaround, thanks. But I still want to understand: whatever "normal" is, why is it change on `GPIO.setup(pin, GPIO.OUT)`? Shouldn't it be and stay in "normal" before and after this instruction? – Dims May 02 '22 at 15:10
  • @Dims Most likely it can't stay "normal" because "normal" = 5V for your relay module and 0V for the Pi GPIO. In more conventional terms, your relay module is "active low" and the Pi GPIO is "active high". "Active" is the opposite of your "normal" - you set a signal to "active" when you want something to happen. Indeed, there's no way for the Pi to know what level is "active" for a random device you bought separately. – Dmitry Grigoryev May 04 '22 at 07:25
  • If normal is 5V for my relay, then why doesn't it trigger when I turn on my device? – Dims May 04 '22 at 08:49
  • @Dims Because the relay module inputs have 5V on them, and the Pi will not apply 0V until you set up the GPIO pin as output. – Dmitry Grigoryev May 04 '22 at 13:38