TIP122 Arduino Relay Tutorial

Using a 12V Automotive Relay with an Arduino

Automotive RelayThe outputs from Arduino can be set to a high or low.  Often times we can set these outputs to drive or signal all kinds of devices.  However, there are limitations.   Specifically, you can not drive devices that require more current that the Arduino can provide.  Specifically,  the Arduino pins are limited to 20 mA.

If you go beyond that limitation by too much or too frequently, you will not only have an unreliable circuit, but you will risk damaging your Arduino.

Instead, we you will need to switch in the necessary current.  One way is to use a relay to drive another.   Another is to use a semiconductor like a transistor, mosfet, or in the case of this article, a TIP122 Darlington Pair Transistor.

Getting the Key Parts

The beauty of this set up is how incredibly cheap it is.

TIP122 Transistors Can be found below:

eBay

Amazon

Automotive Relays are also available at both locations

eBay

Amazon

TIP122 Darlington Pair Transistor Description and Pin Outs

The TIP122 is an NPN Transistor.   In that format, we know that the base requires a voltage that is more positive than the emitter in order to allow current to flow from the emitter to the collector.    The location of the base, emitter and collector of a TIP122 are shown in the picture below.

The neat thing about this transistor is that it allows for as much as 5 amps of current going from the emitter through to the collector and as much as 120 mA going from the emitter through to the base.

Equally cool is the fact that you can have as much as a 100 volt difference from the collector to the emitter and as much as a 100 volt  between the collector and base.

Is It Overkill?  In a lot of cases it is.  However, they’re cheap and I have a ton of them. More, when I’m trying a new idea, I really don’t want to waste time optimizing.  If the idea works and I truly like what I’ve built, I will optimize then.

TIP122 Pin Outs

The Automotive Bosch Cube Relay Pin Outs and Description

These relays come in varying voltage and current ratings.  The one I’m testing with has a 12 Volt Coil Rating and 20/30A contact rating.  The contact rating means that the normally closed contacts are specified for 20A and the normally open contacts are specified for 30A.

The particular relay I have has coil resistance of approximately 95 ohms.   This fundamentally means that the coil will drawn about 130 mA in a car.

The current that the coil requires is way too high for the Arduino output current rating, but well under the 5 A that the TIP122 is capable of handling.

Automotive Bosch Cube Relay Pin Outs

Arduino TIP122 Relay Schematic and Circuit Description

In the schematic below,  a high output on from D0 will forward bias the TIP122 and thus allow current to flow to pin 86 of the relay.  This will energize the relay and the relay will connect pin 30 to pin 87 and thus supply power to whatever device you are trying to energize.

The resistor limits current flow and the diode will suppress transients caused by the collapsing of the relay coil’s magnetic field.

TIP122 Arduino Automotive Relay SchematicArduino TIP122 Automotive Relay Tutorial

In this example, we’re going to build a circuit that uses an Arduino to drive an automotive ice cube relay.   When the sketch is running, the relay will turn on for two seconds and off for two seconds.  This will continue until you remove power from your Arduino.

Build the Arduino Circuit

Its the same circuit you see above, except it is a bit more illustrative.

TIP122 Arduino Relay Drive Tutorial HookupCopy, Paste and Upload the Sketch.

You may wish to remove battery power before you do this.

// Henry's Bench
//TIP122 Arduino Tutorial

int nRelayDrive = 0; // pin zero is our relay drive


void setup() {
  pinMode(nRelayDrive, OUTPUT); // declare relaydrive as an output
  digitalWrite(nRelayDrive, HIGH); //Turn the Relay Off
}

void loop() {
  digitalWrite(nRelayDrive, LOW); // Relay On
  delay(2000);
  digitalWrite(nRelayDrive, HIGH); //Relay Off
  delay(2000);

}

Verify Operation

Remove the USB cable from your computer and reconnect battery power.   Give your Arduino a little time to boot up and listen.  If it’s working, you will hear the relay click on and off.

Final Thoughts

If I were designing this to last, I would not use the car battery power directly to my Arduino.   In a car, that source of power can get quite noisy.  Instead, I would build my own regulated power supply or use a low cost buck converter.

 

6 Comments

  1. Ravi April 6, 2017
  2. Leonardo December 25, 2016
  3. capnfatz@gmail.comAuthor May 9, 2016
  4. Asdrubal May 9, 2016
  5. capnfatz@gmail.comAuthor April 12, 2016
  6. DENNIS April 12, 2016

Add a Comment

Your email address will not be published. Required fields are marked *