John Public
Posts: 88
Joined: Thu Jan 16, 2014 2:16 pm

5v relay board and Raspberry zero

Sun May 06, 2018 7:16 am

I have gotten info on how to use a 5v Relay module with raspberry Pi from viewtopic.php?t=197339
It says that I should use transistor 2n2222 and a resistor r470 as follows.
Image4.jpg
Image4.jpg (118.03 KiB) Viewed 895 times
Unfortunately I don't have 2n2222 but instead have only BC546B. I am using the setup with a Raspberry zero and from the relay unit I am using only one relay and leave the other 3 unused. The relay is used to open/close and electric strike lock (it uses 12V).
How could I use the BC546B with this setup? I also have a zener IN4007 and "4v7 611" and different resistors and leds

wh7qq
Posts: 1087
Joined: Thu Oct 09, 2014 2:50 am

Re: 5v relay board and Raspberry zero

Sun May 06, 2018 8:24 am

I have used a nearly identical 2 channel relay board and it works fine direct from the RPi zero output. Those boards have optically isolated inputs and anti-flyback diodes across the relay coil so you really can;t hurt the RPi with them unless you connect them wrong (like 5v on the GPIO pin). The opto-isolators work fine on the 3.3 volt output of the GPIO pin. Try it...the worst that can happen is that the relay will fail to switch. You can compare the specs of the two transistor types as well as the rest of us, so do your own homework and maybe learn something. The 2N2222 is an old (been made since forever) NPN, general purpose device and most any other small signal NPN transistor will do just as well but you probably will not need to use it. It won't hurt anything to use it but it may be unnecessary with that relay board.

The !N4007 is not a zener but a general purpose rectifier diode with a high reverse voltage breakdown spec that can handle up to an amp of forward current.. No idea what the 4v7 611 is...look it up.

John Public
Posts: 88
Joined: Thu Jan 16, 2014 2:16 pm

Re: 5v relay board and Raspberry zero

Sun May 06, 2018 10:00 am

Would this be OK? Connect RPi0 5v to the relay unit or should I connect 3.3V to VCC instead?
I don't want my zero to fry. The 4V7 is a Zener 4.7V
Attachments
Image3.jpg
Image3.jpg (31.35 KiB) Viewed 864 times

wh7qq
Posts: 1087
Joined: Thu Oct 09, 2014 2:50 am

Re: 5v relay board and Raspberry zero

Sun May 06, 2018 8:15 pm

IIRC the relay coil needs 5V to assure proper actuation and as it is isolated from the RPi GPIO, I would use it. The current capacity of the RPi 3.3V supply is very limited and is provided for the CPU primarily.

John Public
Posts: 88
Joined: Thu Jan 16, 2014 2:16 pm

Re: 5v relay board and Raspberry zero

Mon May 07, 2018 7:27 am

I went ahead and tried with my setup (the one without a transistor). It worked OK - no problems. Most of the time it is turning using the relay ON a 12v connected to a electric strike door lock. When a suitable code is entered it turns the relay off for a few seconds.

wh7qq
Posts: 1087
Joined: Thu Oct 09, 2014 2:50 am

Re: 5v relay board and Raspberry zero

Mon May 07, 2018 7:10 pm

The relay is a SPDT switch...it has both a normally on and a normally off output. Optimally, you want the relay coil energized only when you want the door to be open so you would wire the relay so that the 12VDC is connected to the center and the side that shows as open : ----/ ---- is connected to the other wire to the door. That way, the coil is energized and using power only when it is activated.

If you issue a

Code: Select all

 GPIO write 26 1
command, the door should unlock until a GPIO write 26 0 is issued. Apologies if this is repetitive.

Return to “Add-ons”

Who is online

Users browsing this forum: No registered users and 2 guests