Why do I need a transistor to operate a 5v Relay?

hi all,

I've checked how to correctly connect a relay to the Arduino and followed the instructions to a successful result. However what I don't understand is why do I need a transistor to operate a 5v relay on the Arduino. Wouldn't it be possible to plug the relay between a digital pin and the GND?. All I get when searching about this is how to connect the components but not more and I'm curious about this.

Thanks in advance!

A transistor is used because a relay coil will usually require more current than the microcontroller can safely deliver, which is about 20mA. Drawing too much current is a good way to damage the microcontroller.

There are relays that operate directly from the Arduino. Also, most solid state relays will operate directly from the Arduino, but solid state relays are more expensive and the output-side specs are a bit more critical (you can't use an AC-output solid state relay to control DC, etc.).

Many thanks. Just to be clear in one thing. When you say current, you're talking about mA, right?. I'm asking because in my mother tonge we say current to the voltage and "Intesity" to the amperage... :astonished:

Yep he means the mA

'm asking because in my mother tonge we say current to the voltage and "Intesity" to the amperage

Sounds like a bit of miss translation there. Current is measured in Amps, voltage in Volts they are different things.

Grumpy_Mike:

'm asking because in my mother tonge we say current to the voltage and "Intesity" to the amperage

Sounds like a bit of miss translation there. Current is measured in Amps, voltage in Volts they are different things.

No, it's not a misstranslation. It's just another language.

No, it's not a misstranslation. It's just another language.

If the other language breaks the laws of physics then yes it is a miss translation.

"I went to France. If you want wine, you have to ask for vin. If you want cheese, you have to ask for fromage. It's like the French have a different word for everything." -- George Carlin

:slight_smile:

Yes but if you went to France and asked for vin and you got fromage there would be something wrong.
So if you go to this mystery language and asked for current and you got volts there would also be something wrong.

It's like the French have a different word for everything.

The trouble with the French is that they have no word for entrepreneur - George Bush

What kind of relay is this?

If it's literally a relay (not a board of populated components AND a relay) then you need enough voltage and current draw to energize the coil turning it into an electromagnet (just copper wire with an electric current) and that's the clicky noise you hear.

Since an arduino pin provides only 40ma and to energize the coi, it can (size dependent) take alot of current so then it's time to use a transistor to unburden the Arduino...

cjdelphi:
What kind of relay is this?

If it's literally a relay (not a board of populated components AND a relay) then you need enough voltage and current draw to energize the coil turning it into an electromagnet (just copper wire with an electric current) and that's the clicky noise you hear.

Since an arduino pin provides only 40ma and to energize the coi, it can (size dependent) take alot of current so then it's time to use a transistor to unburden the Arduino...

It's a DPDT 5v M4-5H

Grumpy_Mike:
:slight_smile:

Yes but if you went to France and asked for vin and you got fromage there would be something wrong.
So if you go to this mystery language and asked for current and you got volts there would also be something wrong.

You seem to really honor your user name... the mistery language is Catalan (I didn't think it was important to mention it, sorry). I don't know of any language which was build upon translation from other languages. So your premise is invalid. You can just not presume that if a word sounds the same in diferent laguages it must mean the same thing. That would make language-to-language dicctionaries useless. It just so happens that the same concept has diferent words in diferent languages. For instance, there is verb in German which is "bekommen" and it is translated to english as "to get" (something). It's not unusual for a german person to go for vacations to USA, go to a restaurant and say something like "I become a steak, thanks" to the waitress. I didn't want to make a similar mistake when discussing about current and hence, I asked.

Going back to the question about the current and the transistor... I would have to use another transistor to power on/off a 3.3v laser, right? I got it from a laser pointer and I don't have any specification about it.

Thanks!

OK yeah, but if the word for voltage translates to the word for current in another language, we have a translation problem. Neither language is wrong, it was just translated wrong.

The thing is... Volts and Amps are International Standards - so we should never have that problem.

Just keep in mind when we say current we mean amperage, and we might say "potential" when we mean voltage.

And yeah, anything that will use more than 40 milli-amps will need to be switched by a transistor. Some laser pointers might run on 20mA - you will have to check it with an ammeter, and if it's that low, you might be able to plug it in directly, but be sure before you do it.

jasmine2501:
And yeah, anything that will use more than 40 milli-amps will need to be switched by a transistor. Some laser pointers might run on 20mA - you will have to check it with an ammeter, and if it's that low, you might be able to plug it in directly, but be sure before you do it.

Make that a 20mA limit, not 40mA, and you'll be safe.

Yes, the data sheet says the IO ports can cope with up to 40mA, however, the data sheet also states that all tests were done at up to 20mA and prolonged use at over 20mA is not guaranteed.

Although each I/O port can sink more than the test conditions (20 mA at VCC = 5V, 10 mA at VCC = 3V) under steady state conditions (non-transient), the following must be observed:
ATmega48PA/88PA/168PA/328P:

  • The sum of all IOL , for ports C0 - C5, ADC7, ADC6 should not exceed 100 mA.
  • The sum of all IOL , for ports B0 - B5, D5 - D7, XTAL1, XTAL2 should not exceed 100 mA.
  • The sum of all IOL , for ports D0 - D4, RESET should not exceed 100 mA.

If IOL exceeds the test condition, VOL may exceed the related specification. Pins are not guaranteed to sink current greater than the listed test condition.

Although each I/O port can source more than the test conditions (20 mA at VCC = 5V, 10 mA at VCC = 3V) under steady state conditions (non-transient), the following must be observed:
ATmega48PA/88PA/168PA/328P:

  • The sum of all IOH , for ports C0 - C5, D0- D4, ADC7, RESET should not exceed 150 mA.
  • The sum of all IOH , for ports B0 - B5, D5 - D7, ADC6, XTAL1, XTAL2 should not exceed 150 mA.

If IIOH exceeds the test condition, VOH may exceed the related specification. Pins are not guaranteed to source current greater than the listed test condition.

Oh in that case, yeah you're gonna need a transistor for practically everything. Some of those cheap RED "laser" pointers might run on 20mA but I doubt it's less than that. I have heard lots of stories of bricked controllers because of too much current - probably better to just avoid the situation.