Today I’ll just upload a short how-to article, explaining how to use a relay module. Some time ago I bought a dirt cheap relay module for controlling high power LEDs with a Raspberry Pi on Amazon. One of these modules cost about 2$ (shipping included), which is a fantastic price, so I ordered 5 modules. In this very short article, I want to explain how you can use such a module in one of your projects.
But what is a relay? It is a simple magnetic switch. If it’s supplied with a voltage, a little coil in the relay’s housing will get magnetic and close a contact and therefore it will also close the electrical circuit, just like your light switch. So you could say that a relay is an automatic switch. But what makes it special? Most relays have a way higher voltage and amperage rating than let’s say transistors. My relay module comes with two independent relays on one board. The PCB has some male headers on the right side and one PCB screw-terminal with three ports per relay:
Most of the connections should be pretty self explanatory, but here comes a complete table with the descriptions of each terminal/header:
|VCC||+5V supply voltage for the relay. Might differ if you have a different relay/board, refer to your relay’s datasheet if you are uncertain about your relays supply voltage.|
|INx||Input x for controlling the relay, where x is a whole number. My board has two relays so for example IN1 is for controlling relay 1. Pull this PIN low to close the relay’s output.|
|NOx||Normally Open (NO) contact of the relay. If the relay’s IN pin is high, no current will flow on this terminal.|
|COMx||The ground line of the voltage supply for the consumer.|
|NCx||Normally Closed (NC) contact of the relay. Current will flow through this terminal, if the relay’s IN pin is high.|
Let me give you an example. If you want a 12V motor to turn whenever your first relay’s contacts are closed, you connect one of the motor’s inputs to NO1, your 12V supply’s ground line to COM1 and the IN1 to whatever controls your relay (Let’s say a Raspberry Pi’s GPIO). Afterwards, you connect the VCC and GND pins to a 5V power supply (or in this example your Raspberry Pi) and the motor’s other input to the positive pin of the 12V power supply. Now whenever you pull the relay’s IN1 pin low, the relay’s contacts will be closed and your motor will turn.
Table of contents