I am a newbie in this electronic world and English is not my first language, please be sorry for any inconvenience I may create. It was a long story for me to come up with this writing, let get a bit of understanding on my case first:
- Background requirement: Design a Solid state relay to switch on/off home AC low wattage devices (less than 600W) that:
- Can be turned on/off independently without MCU using a Capacitive touch button (TTP223) (here called as TTP223);
- Can be turned on/off using an MCU pin and if possible allow the MCU to monitor state of the relay using that pin (here called as GPIO).
- Both TTP223 and GPIO form up a XOR logic so that the relay can be toggled using each of the control line (TTP223 or GPIO).
- Development process:
2.1 Developing the Relay:
Quite easy using a Triac BTA16-600BRG (this can drive a load of up to 2A without a dedicated heatsink) and a Zero cross detection optocoupler MOC3041 or MOC3063S. I tested load (inductive and resistive) of 470-500W and the Triac heat up to 45-50 degree celcious and became stable for 20 minutes after about 5 minutes of gradual heating up. I used the cheap Chinese triac (less than 0.15$). The genuine one from ST Microelectronics is better and have higher capacity to capacitive load but cost about 0.5$). BTA16-600BRG is snubberless so I dont need a RC circuitry (but keep it safe to have a R/C pair if you need to drive an inductive load).
2.2 Develop the control interface for the relay
This is the most difficult part for me as a newbie. Google provides me quite some options and I came about the following version:
+ Version 1: Using 2 analog SPDT chips SN74LVC1G3157DBVR to toggle the outputs from the 2 input lines (TTP223 and GPIO) (this is similar to the stair-case switch)
This design worked well. However, I have no way to monitor the output state (on/off)
- Version 2: Develop a circuit to replace the analog SPDT chips. Google tell me that a latching circuit using NE555, CD1403 or UA741 (UA741 required at least 10V to work so I removed this option) can be of help
With C3 and R5, the output will not be engaged at power on. C5 is needed for creating a sharp control pulse from input line (following advice from Swagatam at https://www.homemade-circuits.com/).
They all applied similar approach
THE PROBLEM: To allow the replacement of the SW with external control signal (TTP223 and GPIO), it is required to have a circuit to act similarly to the physical momentary switch. Without much consideration, I jumped into the search for "building a circuit to mimic the SW that allows current from both directions A1<->A2". And I came about the MOSFET bi-directional switch option. And this was the original title of this question. However, from the forum advises, I found this option was a failure (I set up a wrong schematic).
- CD4013 toggle output
- NE555 toggle output
Doing a bit further of studying, I found that the current flow in the switch was just from the capacitor through the switch (one way) at both presses (first press to turn on and second press to turn off). With this consideration, the bi-directional switch is no longer needed and I came about this last schematic as below:
Applying of the CD4013BMS is better than NE555 as the Quiescent is much smaller at 5VDC (~1 micro Amp) and it functions better than NE555 at powering on (no engagement of the output).
- The MCU
This is not too difficult part: I use ESP8266-01S as the MCU with a cheap power module (0.8$) and a PCF8574 port expander. The board is here and can support up to 8 pluggable relays. IO pin on PCF8574 (P0-7) are quasi-bidirectional so they can work both as input and output without a problem (I have tested successfully)
So the programming part for MCU is straight forward:
- Have an variable to set initial state of relay (at power on) as OFF (Relay_state_1)
- Screen the GPIO every 20ms to see if TTP223 is pressed and change the Relay_state_1 to HIGH or LOW respectively.
- The rest will be using Write to set the related pin HIGH/LOW via pfg8574 library
I will test this next week and post the result. So this all of my lengthy story. Thank you very much for your attention.