This tutorial will discuss how to design a relay circuit diagram for any DC or AC loads. By using this relay circuit with Arduino, esp32, or any microcontroller you can drive (ON-OFF) any high-power load like a motor, or a heater.
- 1x Optocoupler (we are using PC817X)
- 1x NPN Transistor (TIP122)
- 1x 5V Relay (SRD-05VDC-SL-C)
- 1x Schottky diode (1N5819)
- 1x Any microcontroller (Arduino, Esp32, Stm32)
- 2x Resistor (330R and 1K)
- 1x 5V Power source
For troubleshooting, some extremely useful test equipment
Best Oscilloscope for Professionals
Best Oscilloscope for Beginners and Students
Best Budget Multimeter
Adjustable Bench Power Supply
Affiliate Disclosure: When you click on links to make a purchase, this can result in this website earning a commission. Affiliate programs and affiliations include, but are not limited to Amazon.com
Relay Circuit Diagram
In this relay circuit, we use an optocoupler (PC817x) to separate the high-voltage part of the circuit (relay part) from the low-voltage part. We connect the anode of the optocoupler to the microcontroller (Arduino, esp32, or any microcontroller) signal pin through a 330-ohm resistor, and the cathode connects to the ground. The collector of the optocoupler is connected to a power source (we use a 5-volt power source). The Emmeter of the optocoupler connects to a transistor’s base (we are using TIP122) via a 1 Kilo-ohm resistor.
The transistor collector pin connects to one pin of the relay coil and the ammeter pin of the transistor is connected to the ground. The other side of the relay coil connects to the power source (5V). We also use a Schottky diode across the relay for reverse current protection.