Simple Relay Circuit
A relay is a simply electromechanical switch. When a magnetic coil is energized the throw of this switch engages and closes the contacts. Relays are commonly used in automotive solutions. They can usually handle high currents and voltages. Because it is a mechanical switch there are a limited number of cycles it can close due to electrical arcing and mechanical plating limitations.
Most relays require 100mA. This is easy when you are a car operating off a 12V battery with a low internal resistance capable of supply hundreds of Amps. For smaller micro controllers it is more difficult and we will need a driver circuit. There are a few options but a BJT is a common solution.
A 100 Ohm Resistor at the base of the resistor biases the transistor. A diode D1 acts to reverse bias the relay when it is de energized.