2
\$\begingroup\$

I have very basic knowledge in electrical engineering. I'm wondering what is the best schematics to use SRD-03V-SLC relay with ESP-12 module?

Here is what I have now: enter image description here

I use input form AC-DC 3.3v 0.9A supply to bring power both to ESP12 and relay You can see ESP-12 is connected through 1K resistor to PC817 optocoupler which drives relay coil. Relays is intended to switch 220VAC not more than 5A

So is such schematics correct/safe?

\$\endgroup\$
2
  • 1
    \$\begingroup\$ You do realise that your optocoupler transistor is acting as an emitter follower and not as a switch. Also you really need to put a diode across the coil of the relay (reverse polarity connected) to prevent damage by back emf. \$\endgroup\$ Oct 30 '16 at 15:09
  • \$\begingroup\$ @JIm Dearden "your optocoupler transistor is acting as an emitter follower" - No, it isn't. The photodiode injects current into the photo-transistor's Collector-Base junction independently of the power supply, so it doesn't matter whether the transistor is connected 'Common Collector' (Emitter follower) or 'Common Emitter' - it will still work the same. \$\endgroup\$ Oct 30 '16 at 19:32
4
\$\begingroup\$

You have the right idea, but your circuit has some problems.

Your 3V relay needs 120mA to operate, but the PC817 optocoupler is only rated for 50mA maximum. Furthermore the optocoupler's CTR (Current Transfer Ratio) could be as low as 50% - requiring up to 240mA LED current to switch 120mA!

So the optocoupler is worse than useless, and since it isn't isolating the relay from your 3.3V power supply there is no reason to have it. You should replace it with an NPN bipolar transistor that can switch 130mA (eg. 2N2222A), or a MOSFET which turns on at 2.5V or less (eg. IRLML2402).

When the relay coil is switched off its inductance will cause a voltage spike as it attempts to keep the current flowing. To prevent damage to the transistor this spike must be suppressed. This is usually done with a diode (eg. 1N4148) connected across the coil in reverse (Cathode to V+).

With these changes the circuit should be safe, provided that you have a good enough isolation barrier between the low and high voltage sides. The most critical point is between the relay's coil connections and COMM terminal, which are only 6mm apart. If you are mounting the relay on a PCB then consider cutting slots between these terminals, to prevent 220VAC from leaking across the board surface.

If the relay is switching an inductive load (eg. motor, transformer) then you may need a snubber across the contacts, to suppress arcing which can damage the contacts and/or cause electrical interference.

\$\endgroup\$
0

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.