5V Relay (Raspberry Pi)

49,644

54

7

Introduction: 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://amzn.to/2VA9pQY

4 Amp Power Adapter - https://amzn.to/2CTptWu

16GB micro SD - https://amzn.to/2SFMwd3

120 pcs jumper cable: https://ebay.to/2VAb9cY

5 Volt Relays: https://amzn.to/2SYHxnH

12 Volt Power Supply - https://amzn.to/2srHmWv

5.5x2.1mm Male+Female DC Power Socket: https://amzn.to/2VA5ZNW

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

Attachments

Step 4: Additional Info

Be the First to Share

    Recommendations

    • Made with Math Contest

      Made with Math Contest
    • Tiny Things Speed Challenge

      Tiny Things Speed Challenge
    • Edible Art Challenge

      Edible Art Challenge

    7 Comments

    0
    ibrahimtheo914
    ibrahimtheo914

    1 year ago

    I wrote the code directly into python and did your steps and it says NameError: name '_name_' is not defined

    0
    nadir.kiyanclar
    nadir.kiyanclar

    Reply 1 year ago

    You need ‘__name__’ (two underscores before and after)

    0
    DilithiumC
    DilithiumC

    2 years 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.

    0
    ibrahimtheo914
    ibrahimtheo914

    Reply 1 year ago

    its max is 250vac 10a or 125vac 15a

    0
    maxwega
    maxwega

    3 years 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.