Solenoid Valve Interfacing With Arduino

Hey guys, welcome back to Techatronic. In this article, we are going to discuss the interfacing of a Solenoid valve with the Arduino. You have to provide the supply of liquid for which you want to control the flow on the one end of the solenoid valve. Just leave the other end or you can also connect a pipe to it as per your requirements. Check more Projects on Arduino made by us. You can also check out our E-book on Arduino which has 10+ amazing projects with well-explained codes. When the power is turned off the liquid will not flow from the other end or the valve is in the off position. To turn the supply on you have to provide the power.

What is a Solenoid Valve

Just like the valves used in your homes for controlling the flow of the water a solenoid valve is used to serve the same purpose. The main difference between an ordinary valve and a solenoid valve is that a solenoid valve can operate automatically. You can program it to work automatically according to the given instructions. In this project, we use an Arduino UNO microcontroller for controlling the solenoid valve. Mainly it is used in the industries. Inside the solenoid valve, there is a coil of insulated copper wire which turns into an electromagnet when you supply the power to it. The valve is open for the flow of liquid when the coil produces a magnetic field around it and cuts the flow when there is no power. The inner mechanism returns to its home position in the absence of electricity. A solenoid valve looks like this.

How Does it Work?

The solenoid valve is used for controlling the flow of any liquid. In this article, we show you the interfacing of the solenoid valve with Arduino and you can make your own projects from it. We use a relay module here if you don’t know how to use a relay module with Arduino then check it first. The solenoid valve can open and close automatically at a regular time interval of 1 second. You can change it by modifying the code. Just complete the circuit and then upload the given code to the Arduino.

Components Required

  • Arduino UNO
  • Solenoid valve
  • Single-channel relay module
  • USB cable for unloading the code
  • Jumper wires
  • 12-volts DC power supply

Circuit Diagram for the Project

solenoid valve with arduino

The circuit diagram is given above, you have to make the connections according to it. Connect the 5-volts pin of the Arduino with the VCC pin of the relay module. Attach the GND pin of the Arduino to the GND pin of the relay module. Join the digital-12 pin of the Arduino to the IN pin of the relay module. On the other side of the relay module connect the positive wire of the 12-volts DC supply and the positive wire of the solenoid valve as shown in the diagram. Attach the negative wire of the 12-volts DC supply to the negative wire of the solenoid valve.

Code for the Project

NOTE: Please upload the code given below to the Arduino as it is.

  void setup()   
  pinMode(12,OUTPUT); // RELAY PIN   
  digitalWrite(12,HIGH); // Normally ON Only For Chanies Relay Module   
  void loop()    
  digitalWrite(12,LOW); // RELAY ON   
  digitalWrite(12,HIGH); // RELAY OFF   

We hope that you completely understand the working of the solenoid valve with Arduino. If you are facing any errors do inform us in the comments section. Please do check out more tutorials on Arduino and Raspberry pi written by us.


Leave a Comment