Arduino water solar heater pump control

arduino

I am still a beginner, and I wanted to do this project

project

which will be fairly easy if I follow the code and the pic, but there is something I don't understand about the relay connection: Why is there a transistor, and why is there a diode, can't I just connect the output pin to a resistor then to the coil pin on the relay?

Best Answer

the transistor is there because the relay operates at 12V and probably wasnt over 100mA of current to operate. the arduino can't provide a signal of that magnitude so the transistor boots its output capability..

The diode is there because the relay contains an electromagnet, and an electromagnet is a type of inductor, and when you try to turn an inductor off it generates a high voltage, which could easily be hundereds of volts. but the BC547 transistor is can only withstand a few tens of volts Vce when the transistor turns off the energy in the inductor forces the switched terminal more positive until it gets to 0.6V above the 12V supply and then the iN4001 starts to conduct the current and he stored energy is burned off as heat in the electromagnet's resistance and in the diode's voltage drop. This is called a freewheeling diode or catch diode

All this complexity could be avoided by using a solid-state relay as they can be triggered directly by the arduino outputs but they can be quite expensive.