I'm looking for a way to do the following WITHOUT a relay.
I have a contact switch with 2 wires that's normally open. I want to connect these 2 wires to 2 Arduino pins (I'm using an ESP8266) and programmatically close the switch, then after a short delay, turn the contact off so that the switch is back to being open. Is this even possible without a relay and if someone has an idea, a snippet of code would be appreciated.
Mike
Why do you want to do this ?
If you are looking for a way to operate a switch on another device using an ESP8266 then start by determining what the switch actually does. For instance, it would be common for a switch to take one of the contacts to VCC or GND when operated,
Depends on how the switch is wired. If it's part of a matrix you will need something like an analog switch (CD4066, 74HC4066, MAX4066).
If the switch has a pull-up on one side and Ground on the other:
// Initialize pin to pulled-up side
pinMode(SwitchPin, INPUT);
// Close switch
pinMode(SwitchPin, OUTPUT);
// Open switch
pinMode(SwitchPin, INPUT);
I have device that needs to be powered off and on remotely. A timer switch will handle that easily. The problem is that when it's powered up, a button needs to be pressed for 10 seconds or so to complete the start up process and since I'm remote I can't do that. So my plan is to open up the device, find the 2 contacts that are crossed when the button is pressed and temporarily close them with the arduino that will power up using the same timer switch.
Thanks, this is promising, I'll look into it
Why the objection to using a relay ?
Just looking for a simpler way. I thought there might be a way to make two pins act as a shunt. It's not a big deal.
Do you even need an Arduino to do this ?
I don't know. I need to close a circuit for about 15 seconds and then open it. It needs to happen about every 3 days. To me it seemed like a $5.00 Arduino would be a cheap easy way to do it but I'm open to suggestion.
Hi, @Mike505
A very important question?
When the contacts are open, what voltage do you measure across it.
Is the button multiplexed?
Is the button part of a potential divider?
If there is a DC voltage across the contacts, then just connecting a microcontroller output to it will not work.
Look up optocouplers they would be a better solution, and not need a driver transistor like a relay would.
https://www.jameco.com/Jameco/workshop/Howitworks/what-is-an-optocoupler-and-how-it-works.html#:~:text=An%20optocoupler%20
Tom...
![]()
555 chips are even cheaper
Thanks to all who responded. This gives me enough to contemplate for now.