Replace Push Button by transistor or optocoupler

Thread Starter

hazim

Joined Jan 3, 2008
435
Hi all.

I am thinking about a way to replace a push button switch with a transistor or optocoupler (but not relay) within a circuit.

The push button is that in a sonoff basic wifi switch.

What I want is, when the mains 220V AC is connected to our designed circuit, after 5-10s it should makes a pulse triggering a transistor or optocoupler that is connected accross the push butttom.
And when the mains 220V Ac is disconnected, it should also make pulse triggering it again but it is not a must to wait 5-10s when electricity goes off.

So, when electricity goes ON, after few second the electronic circuit should trigger that switch electronically (not mechanically through push button). And the same thing should happen again when electricity goes OFF.

There will be another source of 220V AC available all the time. It looks like we will hack this sonoff basic switch.
I'm looking to make it as simple as possible and even try to place the circuit inside the sonoff basic switch encloser.

I was trying to make the circuit using only capacitors, resistors and transistors, without 555 timer and relays, and hope it could be done like that.

Best Regards,
Hazim
 

Attachments

MisterBill2

Joined Jan 23, 2018
18,167
OK, what it seems like is that the TS wants to enable a WIFI remote control box some time after the power is switched on, with a delay of enabling for reasons unspecified. And then disable the WIFI controller after the power is switched off. Probably the delay is to allow another device to wake up so that they can pair, but that is a guess. There is possibly enough room inside that enclosure to add such a circuit, using a dual surface mount 556 device., or two .
 

Thread Starter

hazim

Joined Jan 3, 2008
435
OK, what it seems like is that the TS wants to enable a WIFI remote control box some time after the power is switched on, with a delay of enabling for reasons unspecified. And then disable the WIFI controller after the power is switched off. Probably the delay is to allow another device to wake up so that they can pair, but that is a guess. There is possibly enough room inside that enclosure to add such a circuit, using a dual surface mount 556 device., or two .
Exactly. And the delay is to wait for the device itself to startup if I changed my mind and used the same electricity source, i.e without another source which would be ON all the time. This requires a big capacitor or battery to do the second trigger after power is off.

If it is much easier and simpler without the delay, then let's do it without the delay.
 

Thread Starter

hazim

Joined Jan 3, 2008
435
Look, all I want is to let this Sonoff switch activate other Sonof switches when power is ON in the place this main Sonoff switch is installed, and deactivate them when the power is OFF at the main unit. I can't figure any other way than adding a circuit. Therr is no such option or feature in their mobile app for this thing.
 

MisterBill2

Joined Jan 23, 2018
18,167
The sonoff device is inactive when the power is off. No battery. Of course, it does not send an off command to the other units when the power switches off.
This is another instance of a thread starter not telling us the whole project, and expecting assistance as though folks understood the whole project.
I DO NOT HAVE ANY "MIND READING" ABILITY AT ALL.
The best I can do is guessing, based on a very limited amount of information.
What I guess is that the TS wants to enable and disable a bunch of these devices from one device, for reasons not stated.
Activating and de-activating may be the same as switching on and off, or maybe not. Switching on the mains power is different from activating as I see it. If the plan is to switch on the controlled functions from a bunch of these devices all at once, there are smart phone programs able to run a script and do that already available.
So now that is what I have guessed, it may be right, or not.
 

MisterBill2

Joined Jan 23, 2018
18,167
It is odd that we have such trouble getting real full details of the projects from many TSs.
This does make it hard to help.
It is common for those struggling with a technical problem to always understand that not everybody is familiar with the items involved,and that others may never have even considered some of the aspects of their situation.
And also, that very few of the folks reading these threads have advanced mind reading skills, that is, the ability to instantly perceive the aspects of what another is thinking about. This is especially true at distances of over a mile.
 
I had a similar issue setting up remote switch-on for my bedroom TV. The standby light was too bright to leave the TV on standby, so I used a remote switch for the power. I found that the Smart-Life app I used allowed me to set up a delayed secondary action to turn the TV on via the infrared remote.

If you need to do it electronically, check out monostable vibrator circuits, as they should allow you do this. You'd use a resistor and diode or diode bridge charging a capacitor to ramp up the voltage over a few seconds until it triggered the multivibrator. To turn off, you either use a second monostable circuit triggered by a drop in voltage, or find a frequency doubler type circuit that produces a pulse on both the rise and the fall of the voltage. Note: You need to limit the voltage on the ramping capacitor, otherwise the voltage would keep rising to mains peak voltage - a zener diode should do the trick.

I've attached a really rough diagram. You may need to square off the input waveform so that ripple current won't cause multiple triggering on turn on.
Delayed switch.jpg

When the power is turned off the input voltage for the frequency doubler will drop, triggering a trailing edge pulse. It may be a good idea to decouple this mains powered circuit from the button circuit - a capacitor turning on a Mosfet should do - the mosfet acts as the switch, instead of the pushbutton. Use a 1M resistor between the mosfet gate and ground (-ve).
 

Reloadron

Joined Jan 15, 2015
7,501
It sounds like you want a "delay on make" and a "delay on break" circuit and you have constant mains power available. You also do not want anything electromechanical like a relay. There are turn key off the shelf solutions so you may want to for example Google "delay on make solid state timer" and also "delay on break solid state timer". I also suggest you give this a read and while focused on commercial relay turn key solutions the definitions may help. When the wireless smart switch turned on it initiates a delay trigger before a solid state switch turns on (delay on make) and when the output of your smart switch turns off it also triggers a (delay on break). Either can have preset time. Either can likely fit into a single gang wall box or J-box. Personally I would just buy an over the counter solution since they are very common from manufacturers like Dayton depending on your location.

Ron
 

MisterBill2

Joined Jan 23, 2018
18,167
Really, the correct solution is to create new code that implements the required function. That can be loaded into the master unit which will need to be powered up first.
This is one of the very few cases where it certainly seems that adding code will be the correct choice and best way to go.
 

MisterBill2

Joined Jan 23, 2018
18,167
Because a small mechanical relay would certainly be able to do this with only a few additional components it is unfortunate that the TS is excluding that choice. One alternative is an oscillator/binary counter IC such as a CD4060. Reaching close to the max count would trigger a transistor that would operate the opto-isolator device, and then reaching the max count would reset the system until the next change of the power status. So the delay would be reliable and consistent.

And also unfortunately this sounds a lot like a homework assignment.
 

Reloadron

Joined Jan 15, 2015
7,501
Hi all.

I am thinking about a way to replace a push button switch with a transistor or optocoupler (but not relay) within a circuit.

The push button is that in a sonoff basic wifi switch.

What I want is, when the mains 220V AC is connected to our designed circuit, after 5-10s it should makes a pulse triggering a transistor or optocoupler that is connected accross the push butttom.
And when the mains 220V Ac is disconnected, it should also make pulse triggering it again but it is not a must to wait 5-10s when electricity goes off.

So, when electricity goes ON, after few second the electronic circuit should trigger that switch electronically (not mechanically through push button). And the same thing should happen again when electricity goes OFF.

There will be another source of 220V AC available all the time. It looks like we will hack this sonoff basic switch.
I'm looking to make it as simple as possible and even try to place the circuit inside the sonoff basic switch encloser.

I was trying to make the circuit using only capacitors, resistors and transistors, without 555 timer and relays, and hope it could be done like that.

Best Regards,
Hazim
My thinking is first, you are not going to be able to change of modify your switch. You have a Sonoff Smart Switch which is a N/O switch used to switch line (mains) voltage in either of two methods. I assume you have the Basic R2 Model. The switch is activated in one of two methods. You manually use the push button or IOT (Internet of Things) with an application such as Amazon Alexa or similar. When the switch is activated you want a delay between activation and powering a load. I am not aware of any simple method to hack, modify or change the application code to achieve a delay. Since you have no mention of IOT for turning the Sonoff On/Off and only mention the button press I would just take the switch out and use a delay on make as I mentioned earlier. You end up with something like this:

Delay On Make.png

The web address in the drawing is just one of many DOM (Delay On Make) solid state switches available. When the Sonoff switch is activated it applies a voltage to the delay on make switch. After a preset delay the delay on make outputs 220 VAC. When the Sonoff switch deactivates everything stops as illustrated in the timing diagram. This is a link to the DOM switch used above, again they are easier bought than built just use one which will handle your load current just as the Sonoff switch needs to handle your load current. If you need an additional DOB (Delay On Break) it would be added and after the delay on make deactivates there would be a delay on the load deactivating. While DOM and DOB timing is readily available off the shelf the units including a relay are more common than solid state. Since you want solid state just look for solid state versions.

Ron
 

MisterBill2

Joined Jan 23, 2018
18,167
The ts HAS REPEATED THAT THEY WANT a pulse delivered both after power up and after power down, and somehow this second pulse output will trigger ten additional devices correctly, so that all switch in the same direction at the same time. My bitter experience has been that once devices are communicating no others are allowed in the conversation. Perhaps the TS has a different arrangement somehow. I refrain from wireless stuff because it is rather insecure.
 

Reloadron

Joined Jan 15, 2015
7,501
The ts HAS REPEATED THAT THEY WANT a pulse delivered both after power up and after power down, and somehow this second pulse output will trigger ten additional devices correctly, so that all switch in the same direction at the same time. My bitter experience has been that once devices are communicating no others are allowed in the conversation. Perhaps the TS has a different arrangement somehow. I refrain from wireless stuff because it is rather insecure.
I realize what the thread starter stated. With that in mind why is the thread starter using a wireless switch? They clearly stated what switch they were using. Beats the heck out of me and apparently the thread starter. We went from one Sonoff to a pile of them wanting to do things they simply won't do and weren't designed to do. The more this drags on the more information slowly comes out. I covered all of this sort of nonsense here. Then too I discovered it was already covered here.
Look, all I want is to let this Sonoff switch activate other Sonof switches when power is ON in the place this main Sonoff switch is installed, and deactivate them when the power is OFF at the main unit. I can't figure any other way than adding a circuit. Therr is no such option or feature in their mobile app for this thing.
The switch is not intended for doing that. Why are you even using a WiFi switch for what you want to accomplish. This is making less and less sense. Hopefully someone else has a solution. I sure do not.

Ron
 

Reloadron

Joined Jan 15, 2015
7,501
Thinking more about this here is a suggestion. Way back there Mr. Bill made a suggestion using a counter. Based you your post I would suggest similar. Use your Sonoff if that is what you want. Then I would just get a pile of SSR's for the current you want. Use the switch to start a sequence of however many circuits you want. I guess you want sequential? I would time it slightly differently likely using a uC (micro-controller) for the control line on each. I only suggest using a uC for the timing sequence for ease. You can use any counter you want. You turn on the Sonoff however you choose, Then after a delay you start turning on each SSR sequentially. Use a uC or build using discrete components. Your choice.

Ron
 

MisterBill2

Joined Jan 23, 2018
18,167
Another option is a dedicated computer with a WiFi interface and a sensor input to detect when to switch on and off. Then a simple basic program can use a script to send out the commands. Actually, use a light sensor to switch on the computer with the autostart set on. After bootup it can do the script and then switch off. Leaving will require switching the computer back on and it can run the shut-down script and then switch itself off. And the battery pack only needs to run it for a few minutes at shut down time. A good place for a retired laptop. And cheap, also.
 
Top