ChrisMadog
Posts: 6
Joined: Wed Aug 03, 2016 12:52 pm

Cannot get relay board to release relays

Wed Aug 03, 2016 1:24 pm

Hi everyone,

I'm brand new to the Pi - well, pretty much so.
I've purchased a Pi 2 B+ and two repay boards so I can automate my home.

I can use either Scratch or Python to activate the relays so they switch on just fine - however they won't switch off !

Any clues ? The relay boards have a transistor driver and it has it's own power supply (or I can connect it to the GPIO pin 2 or 4).
The relays are activated with a low.
As I said, I can get them to turn on but not off.

Can anyone point me in the right direction here ?

Regards,
ChrisM

SonOfAMotherlessGoat
Posts: 690
Joined: Tue Jun 16, 2015 6:01 am

Re: Cannot get relay board to release relays

Wed Aug 03, 2016 6:00 pm

Sure, which model relay boards, and a copy of the Python code you are using would help in the troubleshooting of your setup.
Account Inactive

pksato
Posts: 295
Joined: Fri Aug 03, 2012 5:25 pm
Location: Brazil

Re: Cannot get relay board to release relays

Wed Aug 03, 2016 7:55 pm

Hi,
I don't recommend to use these relay board (sainsmart and clones) to control mains AC. Don't have popper isolation and protection.

If relay is activated on low state (0V), and logic/coil side is powered by 5V or 12V, the described situation can happen.
To solve it, use ULN2308 transistor array, this chip invert signal and correct drive relay board.
Need to change software to activate relay on high state.
But, some boards have a option to power logic side with 3v3 (or other voltage) and relay coil site by 5V or 12V.

ChrisMadog
Posts: 6
Joined: Wed Aug 03, 2016 12:52 pm

Re: Cannot get relay board to release relays

Wed Aug 03, 2016 11:40 pm

Hi and thanks for the replies :)

The relay board is this one on ebay:
http://www.ebay.com.au/itm/151899698415 ... EBIDX%3AIT

The relays are activated with a low. It starts up inactivated.
Using either scratch or python it will not release. I'm using the code in the tutorials.

I'm beginning to think that the relay board input (GPIO output may need to be pulled high by a resistor and I'd guess around 10K should be fine. I will try this and see and go down to 2K2 if that doesn't work.

Using Python on the command line, if I exit python after the relays are locked on, they all release again.

I will have to get a capture of the code when I try using pull up resistors later today and I will get back with the results.

Thank you both for your replies. It gave me something to consider.

Regards,
ChrisM

ChrisMadog
Posts: 6
Joined: Wed Aug 03, 2016 12:52 pm

Re: Cannot get relay board to release relays

Thu Aug 04, 2016 12:02 am

Hi pksato,

I agree with you regarding isolation to control high voltage gear. What I will be using is the relay to control proper solid state switches as they have the required isolation - most of them have opto isolators on the input so they are the ones to get.

However, I will be controlling 12V devices mostly - LED lights, door latches etc. so there shouldn't be a problem.
I can get relay boards with built in opto-isolators so if I want to switch high voltage, I will probably go that way or use much higher rating relays if I really need to do so although I don't see why I would want to do so.

Thanks for the warning though. It reinforces my own opinion and who knows, someone else thinking of doing so may do it properly after reading this.

Regards,
ChrisM

ChrisMadog
Posts: 6
Joined: Wed Aug 03, 2016 12:52 pm

Re: Cannot get relay board to release relays

Thu Aug 04, 2016 11:08 am

Okay - I got it.
Problem solved - or at least I know what it is.

The output from the Pi is 3.3V or 0v on the GPIO pins.
The relay board runs from the 5V supply.

So, I operate the relay by bringing the GPIO pin Low (OFF or False).
The relay operates.
Then I make the GPIO pin High (ON or True) and the GPIO pin goes to 3.3V
3.3Volts is not enough for the relay board to see it as 'High' It needs within probably 0.6V of the 5V supply to see it as a valid High to turn off the relays.
I had a 'lightbulb moment' and realised this during dinner, so after dinner I put the Vcc on the relay board to the 3.3V pin (pin 1) on the header and it works perfectly.

Now to work out a solution that works properly as the relays don't do too well on 3.3V

Regards,
ChrisM

Return to “Beginners”