0
\$\begingroup\$

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?

\$\endgroup\$

1 Answer 1

2
\$\begingroup\$

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.

\$\endgroup\$
9
  • 1
    \$\begingroup\$ freewheel, flyback \$\endgroup\$
    – jippie
    Commented Jan 24, 2015 at 12:54
  • \$\begingroup\$ seems this wheel has been reinvented many times, and consequently has many names. \$\endgroup\$ Commented Jan 24, 2015 at 15:03
  • \$\begingroup\$ so if i got a relay with a rated voltage less than 5V i can drop the transistor or i will still need it for the freewheeling diode thing? \$\endgroup\$
    – user28324
    Commented Jan 24, 2015 at 16:23
  • \$\begingroup\$ If the relay works with less than 20mA and a substantially lower voltage than 5V (check the datasheet for the microcontroller!) then it would work but still requires a diode. @user28324 \$\endgroup\$
    – jippie
    Commented Jan 24, 2015 at 19:00
  • \$\begingroup\$ actually i think it's 40 mA ( i will be using UNO ) thanks \$\endgroup\$
    – user28324
    Commented Jan 24, 2015 at 21:25

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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