5V Relay (Raspberry Pi)

About: the Raspberry Pi is Awesome!

Basic tutorial of how to setup a 5V Relay with the Raspberry Pi.

Step 1: Parts

RPI 3 – https://goo.gl/CdVNoH

4 Amp Power Adapter – https://goo.gl/js4Uc7

16GB Micro SD – https://goo.gl/FDqZal

120 pcs jumper cable: https://goo.gl/FDqZal

5 Volt Relays: https://goo.gl/FDqZal

12 Volt Power Supply: https://goo.gl/FDqZal

5.5×2.1mm Male+Female DC Power Socket: https://goo.gl/FDqZal

Step 2: Setup

VCC -> 5 volt pin

GND -> Ground pin

IN -> GPIO 21

*Ensure postive leads are hooked up to NO and C terminals

Step 3: Code

1. Copy Script to Raspberry Pi

2. Type "python relay.py" to run

Step 4: Additional Info



    • Big and Small Contest

      Big and Small Contest
    • PCB Contest

      PCB Contest
    • Toys Contest

      Toys Contest

    3 Discussions


    8 days ago

    I connected a 5v relay to raspberry-pi 3b+, 12v peristaltic pump and 12v Li-ion battery. And the pump works but my question is can the 5v relay handle this or should I get a 12v relay.


    9 months ago

    nice project. will like to try it. can we use the relay as a regular switch. i mean here you are using it with 12 volts DC power supply and motor, what if i want to use it with a regular light bulb and mains power supply. will it support or blow up.