This is the circuit that I have come up after checking many others:
I have seen multiple circuits using, for example, a BJT but I am not sure how to calculate the resistances and which BJT to choose. Would the BC860 be a good option, given that the relay needs 11,7mA ?
As far as I can tell, an ESP32 GPIO could supply around 12mA through its 3V3 GPIO and checking that the optocoupler has an input forward voltage of 1.2V, the R1 could be 220 to provide a safe 10mA to activate the optocoupler output.
At this point I am not sure how to calculate:
- R2 and R3 (If this is a good circuit.)
- R4 I am not sure if it is necessary since the G6S-2 has 1.028Ohm for the 12V version.
- Q1 - Is the BC860 a good candidate or should I use another?
I have also come up with this other version, where the optocoupler is activated using a low GPIO signal:
Which one of those 2 solutions would be the best to use? Are they correct?