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
1 view
57
10
2 days ago 03:33:33 5
Just Listen! Frequency Of God 1111 Hz: Unexplainable Miracles Will Extend To Your Entire Life
2 days ago 00:50:40 1
Загадка скрипок Страдивари -документальный фильм Violin Stradivarius
4 days ago 00:33:58 3
MEDIA LITERACY TRAINING: How predatory marketing is manipulating you
5 days ago 00:00:00 1
“BEL90A Ring Laser Gyroscope – Precision Navigation for Unmanned Vessels“
5 days ago 00:03:16 1
How to Draw a Spider Easy Step by Step
1 week ago 00:42:10 5
Tommy Robinson - The Untold Story
1 week ago 00:06:12 1
साबूदाना की बर्फी | नवरात्रि स्पेशल व्रत की
1 week ago 00:03:22 2
Haddaway - What Is Love (Shuffle Dance Music Video) 💃【4K】
1 week ago 00:02:41 1
[2025 DREAM WEEK] How to Make TOMORROW X TOGETHER
1 week ago 00:20:15 2
Karoline Leavitt’s Lifestyle 2025★ House Tour, Husband, Children, Cars, Net Worth....
1 week ago 00:04:29 3
After Dark - (Music Video - Lost In Translation)
2 weeks ago 00:00:00 1
Bucha Massacre Row At UN LIVE | Putin Aide ‘Proves’ How Kyiv & UK Conspired To Defame Russia
2 weeks ago 00:03:44 18
. 2: HEART OF CHORNOBYL | 1980’s LIVE-ACTION MOVIE
2 weeks ago 00:06:52 10
Rentarou’s love speech with ENG subs | Hyakkano/100 girlfriends
2 weeks ago 00:00:37 1
Revolutionary Skin Grafting Technique Revealed!
2 weeks ago 00:00:36 1
Corner Not Square? Do this. #tipcentric
2 weeks ago 00:03:48 1
OFFICIAL Somewhere over the Rainbow - Israel “IZ“ Kamakawiwoʻole
2 weeks ago 00:10:17 6
17+ Pretty Blood : Red Snow Part 2
2 weeks ago 00:02:35 1
Tate McRae - greedy (Official Video)
2 weeks ago 00:04:19 8
Al Bano & Romina Power - Liberta
2 weeks ago 00:27:20 4
MACRAME OWL Plant Hanger 🦉 Flower Pot Holder (DIY)
2 weeks ago 00:11:43 1
Revolutionizing Interior Design with AI: A Stunning Demo
2 weeks ago 00:06:59 1
자연산 광어 대광어 오로시 해체작업, How to Cut a Huge Flatfish?! Flounder Sashimi, 길거리 음식, Korean Street Food
2 weeks ago 00:12:19 1
DIY daily tote bag,. Zippered bag tutorials for beginners.