How To Control A Solenoid With A Raspberry Pi Using a Relay
Subscribe For More!
Demonstrated here is an easy way to control a 12 Volt Solenoid and a 5V Relay using a GPIO Pin on a Raspberry Pi.
Article with Code -
Related Information
Control Your Raspberry Pi Remotely Using Your Phone (RaspController Guide) -
Controlling a 5V Solenoid with an Arduino -
Control One or Two Servo Control With Raspberry Pi -
Control 16 Servo via Adafruit HAT for Raspberry Pi -
Dual Monitors with Raspberry Pi (Excellent Beginner Guide to Connecting Everything Up) -
Facial Recognition with a Raspberry Pi and OpenCV -
Solenoids are immensely useful way to turn electrical energy into a linear motion. Solenoids come in a variety of different specs with 5 Volt and 12 Volt being very common for makers. So today we will activate the stronger 12 Volt solenoid using the Raspberry Pi GPIO (General Purpose Input and Output) Pin with a Relay module in between the two. A relay is an electrically operated switch and we need one for this because the 12 Volts that the Solenoid requires to operate would fry the Raspberry Pi if directly connected to that voltage as the maximum voltage it can take is 5 Volts. It can also deal with voltage spikes. Here you can find schematics, how to wire it up correctly and how to write code to activate and deactivate any 12V solenoid. I even show how you can control it directly from your mobile phone. Shown here is a latch solenoid but there are more traditional plunger type solenoid and even liquid solenoids.
If you have any questions about this content or want to share a project you’re working on head over to our maker forum, we are full time makers and here to help -
Core Electronics is located in the heart of Newcastle, Australia. We’re powered by makers, for makers. Drop by if you are looking for:
Latch Solenoid 12V (used here):
5V Single Channel Relay Module 10A (used here):
Raspberry Pi HAT 3X Relay:
Plastic Water Solenoid 12V:
Brass Liquid Solenoid 12V:
Raspberry Pi 4 Model B 2GB:
12V DC 2A Fixed Plugpack:
0:00 Intro and Schematic
0:10 Overview of Video
0:29 What You Will Need
1:47 Schematic and Build
3:13 Coding the Raspberry Pi
3:50 Its Working!
4:00 Quickly Explaining the Code
5:20 Control It With Your Phone
5:33 Other Relay Types and Methods to Control
6:00 Outro
0 views
57
10
1 week ago 00:52:27 0
Awakened Christ Consciousness: The Hidden Message of Jesus Revealed
1 week ago 00:04:21 0
Getting Pregnant after 36 | Best ways to Natural Conception without IVF and IUI- Aasha Ayurveda
1 week ago 00:04:14 0
How EVIL VITALITY Really Plays CS2
1 week ago 00:09:32 0
Making a Teddy Bear Keychain with Hair Rubber Bands and Sewing Thread / Incredibly Simple Steps
1 week ago 00:10:38 19
Rear Choke Submission! | Jena Bishop v Ekaterina Shakalova | Full Fight | PFL WT 6 2025
1 week ago 00:04:24 1
CryptoPromo – The Leading Crypto Marketing Platform in 2025?
2 weeks ago 00:00:24 0
The Most Adorable Monster in Japanese History
2 weeks ago 00:03:15 0
The Wallet Gesture and Invitation by Pastor Lance Edminster 2025 06-29
2 weeks ago 00:12:59 0
Americans Invented a New Christianity: Here’s Why That’s Terrifying
2 weeks ago 00:03:55 12
English Christian Song | “Those Who Are Not Acknowledged by God“
2 weeks ago 00:00:30 2
hadama #funnyclip #baby
2 weeks ago 00:04:35 10
Jeff Bezos’ $10M Venice Wedding: Inside the Lavish Celebration & Celebrity Guest List | NEWSDRIFT
2 weeks ago 00:12:56 0
Google’s AI Found a Glitch in Reality — And It’s Getting Worse
2 weeks ago 00:00:34 1
Background suppression optical sensor! High sensitivity, strong stability, handle any environment.
2 weeks ago 00:03:02 0
CryptoPromo – How to Market a Crypto Project in 2025 (Step-by-Step Guide)
2 weeks ago 00:14:02 1
DIY Puffy Boxy Quilted Patchwork Travel/ Makeup Bag Swing Tutorial
2 weeks ago 00:07:36 1
P Diddy Darts Eyes at Federal Prosecutor as She Rips Him in Closings
2 weeks ago 00:35:25 0
Теория Большого Взрыва — убита Джеймсом Уэббом?
2 weeks ago 00:00:13 0
My Home’s ’Luxury Feel’ Secret: Wood Blinds Are This Beautiful!
2 weeks ago 00:52:26 1
WWII: The Secret Financial Deal That Kept Hitler in Power - Historical Documentary - AMP
2 weeks ago 00:13:32 1
Surprising Way to Support Your Liver and Lose Fat!
2 weeks ago 00:07:47 0
The World’s First Flying Humanoid Robot
2 weeks ago 00:30:59 1
Шью детское лоскутное одеяло. Одеяло за час. Лоскутное шитье, остатки в дело. Пэчворк.
2 weeks ago 00:06:49 0
Tutorial: How to make your first edit in Liquipedia