As it is known, the microcontroller for obvious reasons can control the electromagnetic relay only through a special driver and most often this driver is the simplest transistor switch. In this article I will calculate the transistor switch for the relay TRS-12VDC-SB-L15 (12V).
For the correct choice of the transistor, it is desirable to consider the so-called strength factor equal to 1.5 (Ic = 12mA*1.5 = 18mA) and for such a load current is quite suitable transistor C1921 with a maximum collector current of 50mA which I have here are in stock.
► 1. The load of the transistor is a relay (TRS-12VDC-SB-L15) with a coil resistance of 970 ohms (Rc). Calculate the collector current of the transistor (Ic):
The saturation coefficient of the transistor (S) for such transistor switches is recommended to be taken within 3...5, therefore, in step 2 of my calculation I took S = 4. This ensures a sufficient level of saturation of the transistor to bring one to the open state.
To test this relay module, I used a standard sketch for blinking LED through the 13th pin with a time delay of 1 second, after changing the variable name for this pin and the number of this pin. Everything is very simple here and it does not need a special detailed explanation.
For visual control of the current state of the relay module (ON/OFF), I soldered parallel to the relay coil (12V) a LED with a resistor of 1 kilohm and this is not shown on the diagram (left).