I'm trying to make an ESP-12s control 2 relays to switch an AC contactor.

I made this schematic in Altium and posted to ask if it will work.

The 2 DC power supplies (3.3V and 5V) are isolated.

enter image description here


Each relay coil + led current take about 80mA. The BC847C is a bit marginal, rated at 100mA, so I would use a better transistor like BC817 or 2222A. I would reduce R13 an R23 to maybe 3.9k to drive the transistor harder, giving a base current ~1mA.

I might add a resistor 10k base to emitter on each transistor. This would sink any opto leakage current when switched off and keep the transistor firmly off. The datasheets for the genuine PC817C suggest this leakage is tiny (<0.1uA), so probably unnecessary.

The PC817C datasheet gives a CTR of 50%, so to drive 1mA into the transistor, you want at least 2mA through the led of Q22.

The voltage drop of the led in Q22 (1.2v) + voltage drop LED32 (depends on led, red led ~1.8v)is close to the 3.3v from the ESP, so the voltage across R32 is small. This means R32 needs to be small, and the led current will vary a lot with led type, temperature and accuracy of the 3v3 supply.

Why not leave the LED32 out, as you have on an led on the relay, this gives

R32 = (3.3V - 1.8V) ÷ 2mA = 750ohm, use 680ohm.

Same for Q12,LED31, R31.

Good luck.

Edit: Wire led in parallel like this. Choose resistor value to set brightness, and dont use white led as volts drop is too high.

parallel led

Or to check the isolator led is not open circuit

enter image description here

Remember max ESP8266 pin source current is 12mA.

Edit: Check on Altium, You may need to add a +5 port symbol to the top 5V rail

5V port

  • \$\begingroup\$ Thanks very much, I'm appreciate. I use LED32 to check the opto is working PC817C's datasheet tell CTR min 200%, so I calculate current through optp led is 0.5mA, so base current is 1mA \$\endgroup\$ May 8 '19 at 7:57
  • \$\begingroup\$ BC847C's datasheet say hfe min is 420, so I calculated, Relay need 100mA / 420 = ~0.25 mA is it correct calculated? Sorry I don't familiar with comment, new line use 'shift+ enter', I just 'enter' or 'ctrl + enter', so there are many edits \$\endgroup\$ May 8 '19 at 8:21
  • \$\begingroup\$ hfe and hFE are not the same. Look at nexperia datasheet figure 4, d.c. gain reduces at higher currents. You want the transistor fully turned on (saturated) or it will get hot, so give it more than it needs. \$\endgroup\$ May 8 '19 at 8:31
  • \$\begingroup\$ I see, thanks for your help, one more question, If I need LED32, what I need to do? \$\endgroup\$ May 8 '19 at 11:37

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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