 Hi, today we'll be learning about relays, both mechanical and solid state relays. Now a few videos ago I talked about how transistors revolutionize electronics by their ability to switch on and off huge electrical loads without any moving parts, just using a small electrical current. Now relays can do the exact same thing, they do the same job, but how they do that switching on and off of a high load is different. A relay will isolate the input voltage that turns the relay on from the load while a transistor needs to sync the input voltage that turns the transistor on through the load. Now this sounds a little complicated but I'll explain it more in depth as the video progresses. Now two types of relays exist, mechanical and solid state relays. Let's start with the simple mechanical relay. So here I have a simple 12 volt mechanical relay and we're going to tear it apart to see how it works. First of all this is what a relay looks like and using a simple screwdriver we can pop the top off and you can see the insides. So if we power it on you can physically see the mechanical relay moving to turn it on. But that's not enough, let's actually take some wire cutters, cut it open and see how it works. So having cut it open you can see the core of the relay, it's a electromagnet as the electromagnet actually activates and allows these contacts to physically move using a lever arm. These relays rely on this physical strip of metal to conduct electricity, they can conduct a lot more voltage and current than your average transistor. If you choose to use a high power transistor instead, a relay can be a much more cost effective solution as well. However, this mechanical nature also provides some downsides. Firstly relays are much larger in their physical footprint compared to transistors. This is because again they have to house an electromagnet, physical space for moving contacts etc. The relays are also not great for switching signals, that means signals that turn the relay on and off very rapidly are not suitable for the relay because the relay takes time to physically move its arm up and down unlike a transistor that can actuate incredibly fast. Multiple different types of relay configurations exist. So firstly here we have this single pole single throw relay, it's a very simple relay that can either be on or off, that's it, just one channel of electricity. Now secondly we have a single pole double throw relay, this will have two states where depending on the side that the relay is flipped towards, one side will be conductive or the other side will be conductive. Thirdly here we have the double pole single throw relay. Now this looks a little complicated but how it works is there's a linking arm between the two different poles, so this only leads to two states either on or off. What the advantage of this is that you can actually control two separate circuits each on their own lane. Now pole refers to the number of outputs while throw refers to the number of positions or states per output. Although relays can handle a much higher power, it's imperative that we do not run more voltage or current than the relay is designed for. The reason for this is firstly the mechanical gap. Now if we run an extremely high voltage across the load, what can happen is that because of this physical air gap, the current can actually arc across the contacts and possibly even damaging your relay. Furthermore if too much power is being drawn while the relay is in its contactive position, what can actually happen is that the two contacts can fuse permanently turning the relay on so even though you try to power off the relay that means flip the contact up, the relay is now fused and is useless. Now electrical snubber circuit as you can see here can actually prevent damage to your relay by adding a simple capacitor in parallel to the load of your relay. We must also be careful with relays since as they're powering off that means once they going from the conductive to a non-conductive state, what happens is that the electromagnet inside releases a back EMF. This is very similar to a DC motor freewheeling that means running. It acts like a generator and will send a small current back to the device that's turning on or off the relay. By adding a simple flywheel diode or a simple reverse current protection diode, we can actually prevent the relay from potentially damaging our input device. You can watch my crash course tutorial on diodes to understand how that works. So far it might seem that relays have too many drawbacks or complications while solid state relays which we're going to talk about next actually mitigate most of the problems of a mechanical relay. Now how they work is that the input current from your microcontroller or controlling device will actually turn on a small light within the solid state relay. Now this light from the solid state relay will go to the other part of the solid state relay where there's a small light sensor, a photo cell and now when this photo cell detects that there's light being illuminated on it, it will in turn activate a triac. Now the triac will switch your load on and off and in turn make your relay conductive or non-conductive. Now a solid state relay might sound like a transistor. They both are switching on high loads without any physical moving parts. But transistors use semiconductors and furthermore transistors have to sync the input current into the load while a relay, a solid state relay doesn't have to do that. The circuit responsible for driving the light that turns on the relay and the circuit responsible for driving the load, controlling the load, the light sensor are both mechanically separated. There is no electrical link between the two. Let's do a quick relay demo circuit over here. The circuit is going to control an LED on the side and as you can see I'm using a 5V relay here so you can use it with the Raspberry Pi or Arduino. So this is the core that we're going to use. It's a simple blink example for the Arduino and instead of having the LED blink we're going to instead activate the relay at an interval of one second and as you can see here is the test code it turns on and off. Now throughout this tutorial I've talked about multiple electronics such as diodes, DC resistors, transistors, photocells or light dependent resistors. Now if you want to learn more about each of these electronic parts do check out my whole electronic crash course playlist down below where I've made tutorials on all these. Do note that this is a very introductory look into what relays are and how you can use them. If you want a more detailed explanation of how they work you can look at the article I've written down below or follow the links that I've posted down in the comments below. Now if you want to subscribe for more electronic crash course tutorials like these do feel free to do that and thanks for watching.