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:

  1. 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).
  1. 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). BTA16-600B triac

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) Toggle the output using 2 control lines

This design worked well. However, I have no way to monitor the output state (on/off) enter image description here

  • 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 NE555 toggle output with 2 control line

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 CD4013 and toggle momentary button
  • NE555 toggle output NE555 toggle output with momentary button 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: Replacement of the switch SW with BC847

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).

  1. 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) MCU top view 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 enter image description here I will test this next week and post the result. So this all of my lengthy story. Thank you very much for your attention.
  • 1
    \$\begingroup\$ No. You would normally tie both sources together. But for a NMOS bidirectional switch you need a floating gate drive. \$\endgroup\$
    – DKNguyen
    Commented Apr 15, 2021 at 5:48
  • \$\begingroup\$ I have the Source tied together, gate connected together to a voltage divider (around 2.5V). Vgs is about 2.5V! \$\endgroup\$ Commented Apr 15, 2021 at 5:52
  • \$\begingroup\$ Oh wait, you do. Your transistors are flipped so it looked strange. \$\endgroup\$
    – DKNguyen
    Commented Apr 15, 2021 at 5:53
  • \$\begingroup\$ I am a bit confused. What is Vgs when the FET's are on? 2N7002 needs like Vgs of 5V to re really on. \$\endgroup\$
    – user57037
    Commented Apr 15, 2021 at 6:18
  • 1
    \$\begingroup\$ Vgs(th) is NOT sufficient to really turn on the MOSFET. You need to get much higher. Do a little searching because I know I have explained this at length many times. I don't want to just keep posting the same information over and over. \$\endgroup\$
    – user57037
    Commented Apr 15, 2021 at 6:46

1 Answer 1


You have to use a photovoltaic array isolator, the usual optocoupler can't be used here. There are those IC that already embed a gate driver purposely for driving N-MOSFET solid state switch.

enter image description here

By the way, your 2N7002 has a gate threshold voltage of 2.5V, it means that at this voltage it "starts to feel", to put a transistor to a conduction required as a switch, you need to provide higher voltage than that.



simulate this circuit – Schematic created using CircuitLab

Why not use a pair of P-MOSFETs?

  • \$\begingroup\$ I accidentally used n-channel already! That why I would like to ask whether my schematic is ok! I will have time to test it next week! I followed this: ti.com/lit/an/slva948/… (Figure 13). I dont use a general NMOS to trigger the back2back NMOS! \$\endgroup\$ Commented Apr 15, 2021 at 7:19
  • \$\begingroup\$ I think that all user comments make clear that your schematics is not OK. \$\endgroup\$ Commented Apr 15, 2021 at 7:22
  • \$\begingroup\$ Okie, thank you for your all comments! I will make some revision! \$\endgroup\$ Commented Apr 15, 2021 at 7:28
  • \$\begingroup\$ I finally found an approach here: vishnumaiea.in/projects/hardware/… \$\endgroup\$ Commented Apr 15, 2021 at 16:24
  • \$\begingroup\$ @ĐặngĐìnhNgọc That's not even nearly about what you were asking for. \$\endgroup\$ Commented Apr 15, 2021 at 21:31

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.