How to bypass/activate external switch with relay, relay activates on boot

Hello,

I am working on a project were I would like my Uno to activate the switch on a garage door opener remote control. I have located the contacts on the board of the wireless garage door opener that when the shorted, the opener function is activated. I understand this does not require power and is simply closing the circuit.

I have a Tolako 5v Relay Module w/srd-05vdc-sl-c for my project. What I have tried is to connect my coil to power and the my switch lead to PIN 13 on the Uno. Initially, chose 13 because of the LED so I can tell when it was activated, but now with the relay I hear the clicking. On the opposite side of my relay I connected my leads to the common and Normally Open connections to either side of my switch on my garage door opener remote.

This seems to work as far as when 5V is applied to the switch lead of the relay switches and activates the garage door opener function. The issue is when I power up everything with this setup the garage door opens on boot. I uploaded blank code to the Uno and this continues to happen so it isn’t my code. If I disconnect the switch lead from PIN 13 and just leave the coil powered I hear the rapid clicking on power-up, but no unattended activation of the switch.

This leads me to believe that I am misunderstanding my setup needs. What am I missing? How can I correct this so that I don’t get an activation of the garage door remote upon power up?

See attached sketch.

Thanks!

Did you initialize pin 13 to be LOW in the setup loop?

DaleScott:
Did you initialize pin 13 to be LOW in the setup loop?

Thanks for the help. This is the code related to PIN 13. Even with a blank project uploaded I hear the relay rapidly click on power up and then the garage door remote pulse once. I did not specifically set it to low as I figured with no code if it still did it the issue was more my physical setup. Do you suggest I put digitalWrite(OpenerPin, LOW) in the setup?

SETUP
int OpenerPin=13; // Garage Opener Connected to Pin 13
pinMode(OpenerPin, OUTPUT); // Set as an OUTPUT Pin
---> Here?

LOOP Excerpt
digitalWrite(OpenerPin, HIGH); // Turn on 5V - OPEN DOOR
delay(OpenerDelay);
digitalWrite(OpenerPin, LOW); // Off on 5V - Stop open door signal

Hi,
Your code excerpt.

SETUP
int OpenerPin=13;             // Garage Opener Connected to Pin 13
pinMode(OpenerPin, OUTPUT);     // Set as an OUTPUT Pin
--->  Here?   



LOOP Excerpt                                      
digitalWrite(OpenerPin, HIGH);              // Turn on 5V - OPEN DOOR
delay(OpenerDelay);           
digitalWrite(OpenerPin, LOW);                // Off on 5V - Stop open door signal

Put your dooropener on pin 12 instead of pin13.
Change your code to this.

int OpenerPin=12;             // Garage Opener Connected to Pin 12
int IndicatorPin = 13;      //Indicator LED Pin13

SETUP
pinMode(OpenerPin, OUTPUT);     // Set as an OUTPUT Pin
pinMode(IndicatorPin, OUTPUT);     // Set as an OUTPUT Pin
digitalWrite(OpenerPin, LOW);                // Initialise output LOW 
digitalWrite(IndicatorPin, LOW);                // Initialise output LOW 
--->  Here?   



LOOP Excerpt                                      
digitalWrite(OpenerPin, HIGH);              // Turn on 5V - OPEN DOOR
digitalWrite(IndicatorPin, HIGH);              // Turn on 5V - LED ON
delay(OpenerDelay);           
digitalWrite(OpenerPin, LOW);                // Off on 5V - Stop open door signal  
digitalWrite(IndicatorPin, LOW);                // Off on 5V - LED OFF

Pin 13 blinks while code is being started.
The bootloader causes this to indicate the controller is starting code.
So your relay chatters on startup.

Using the edited code, Pin13 will still blink, but pin12 will not while loading code, but will still operate as an indicator for your relay code.

Hope this helps.

Tom... :slight_smile:

@TomGeorge

VERY HELPFUL. As I was writing my post I as wondering if the LED had something to do with the issue. I see you also advise to set the output to low right in the declaration. I will update my code and test Monday when I have access to the hardware.

Much Appreciated
Mike