2 Channel Relay Issue on blackout

Hi guys, Ive setup a garage open and close sketch on my arduino and it works great.
I have the open door connection connected to relay 1
I have the close door connection connected to relay 2

The only drama i have is when the connection is on "NC" with a blackout the relay closes the circuit when the power comes on and opens the garage door. If the connection is on "NO" with a blackout the relay closes the circuit when the power turns off and opens the garage door.

The relay is one of those cheap Chinese ones so that could be the issue, I just want to check with you guys for options first.

Any suggestions would be greatly appreciated.

Please read the forum guide in the sticky post.

You're probably not using just a relay but a relay module. Please provide a link.

But you probably need to add a pull resistor in the right direction to keep the relay in the state you like. And it would make sense to make that the OFF state of the relay and to use the NO contact on the relay to control stuff.

Hmm, now that you mention it, possibly seeing the old problem with the active-low opto-coupled relay modules where you set the control pin to OUTPUT before writing it HIGH and it briefly "glitches". :astonished:

Pull-up resistors will not fix that.

Mm, true. The low impedance will indeed keep them in the right state. But easy to fix though :slight_smile: If only details....

Hi,
Welcome to the forum.

Please read the first post in any forum entitled how to use this forum.
http://forum.arduino.cc/index.php/topic,148850.0.html . Then look down to item #7 about how to post your code.
It will be formatted in a scrolling window that makes it easier to read.

Can you please post a copy of your circuit, in CAD or a picture of a hand drawn circuit in jpg, png?

Thanks.. Tom.. :slight_smile:

Thanks guys, I have no idea about the schematics. The relay is a relay module (attached)
Relay 1 running off pin 3
Relay 2 running off pin 6
and the sketch running is also attached. Perhaps there is something in the code that I can amend.
The android plugin im running is autoarduino which calls pins High and Low using tasker.
But as I said the issue is a blackout fault and only happens turning on and off of the arduino and relay module.

arduino garage door.ino (10.1 KB)

thomasj7:
I have no idea about the schematics.

That's of course utterly BS. You connected it, didn't you? So you can draw a schematic. Hand drawing will do.

And that's

a weird sketch.... ::slight_smile:

Using pin 3 for the relay seems a bit odd:

attachInterrupt(digitalPinToInterrupt(3), pin3Changed, CHANGE);

You seem to use it for something else as well. What that is, no idea. Because the complete lack of useful variable names ::slight_smile:

And yes, that seems an active LOW driver. Do

digitalWrite(pin, HIGH);
//BEFORE
pinMode(pin, OUTPUT);

And have the thing you control connected to the NO contact.

Hi,
What model Arduino are you using?

Tom... :slight_smile:

septillion, thankyou that totally fixed the issue. Appreciate your assistance and expertise.

Question regarding your door operation.

Could you explain further the below operation? I ask because my doors have always required a momentary contact to open or close.

I have the open door connection connected to relay 1
I have the close door connection connected to relay 2

On my garage motor controller i have up only and down only buttons. I just ran the positive and negative of the buttons back to the relay modules. Previously it was setup just to the garage door button which was either up or down and you never new which direction it was going. As far as getting any more advanced than that, I would require help on here.