Latest revision as of 13:33, 18 August 2018
Using a relay is very helpful when trying to power something with a raspberry pi that requires more than 5v. To be able to do this you are going to need a raspberry pi, a relay, and an external power supply.
The first step is to connect the raspberry pi to the relay. The first step is to connect a ground pin on the raspberry pi to the GND pin on the relay. Next, connect one of the 5v pins on the raspberry pi to the VCC pin on the relay. Finally, connect any of the GPIO pins on the raspberry pi and connect it to any of the IN1 - IN4 pins on the relay depending on which relay is used. For this tutorial, the images shown are from a 4 channel relay but relays can have anywhere from 1 to 8 channels. It all depends on how many things you need to power.
The last thing you need to do is connect the external power supply to the relay. The positive end of the power supply will go in the middle of the 3 ports. The negative end of the power supply is going to go to what you are trying to power. Next, take a wire and put it in the port on the right, this port has a normally open connection which means that the circuit powering the device will not be completed until a current is being sent to the relay. Finally, take the wire from the port on the right and connect it to the device being powered.
All you have to do now is code the raspberry pi to turn on the GPIO pin that you connected to the relay and the circuit will be complete.