This tutorial is based on the Automatic Water Tap control system using Arduino Uno or Mega, 12-volt Solenoid Valve, Infrared Sensor and a 12-volt SPDT type relay. The main purpose of this project is to stop wasting water. The flow of water is controlled automatically using the IR “Infrared Sensor”. When the infrared Sensor detects the hand the solenoid value is Turned ON, while in the absence of the hand the solenoid valve is turned off.
The Automatic water tap control system project can be used in Colleges, homes, Universities, buildings, etc. If this project is implemented everywhere the water problem can be solved, as there will be no wastage of water.
This Tutorial covers the following.
- What is a Solenoid Valve?
- How to find the resistance of the solenoid valve coil
- How to perform the relay driver circuit design calculations.
- Finally testing the whole project.
The purchase links of the Automatic Water Tap are given below:
solenoid valve: https://amzn.to/2EWsmX0
Arduino Uno: https://amzn.to/39aq6ZT
Mega 2560: https://amzn.to/2SszMsI
lm7805 Voltage Regulator: https://amzn.to/2ERYoTJ
330-ohm resistors pack: https://amzn.to/2Qj1Igg
female DC power jack socket: https://amzn.to/377Pg9M
470uf capacitors: https://amzn.to/2MrN3xR
5×7 cm Vero board: https://amzn.to/37b7KWO
female headers: https://amzn.to/350w6RE
connection wires: https://amzn.to/2MvOJXd
Super Starter kit for Beginners: https://amzn.to/398dliF
Jumper Wires: https://amzn.to/2SrnBwo
Bread Board: https://amzn.to/2MxV5FM
12v Adaptor: https://amzn.to/2MuOlZk
PCB plate: https://amzn.to/2MuwNMB
Variable Supply: https://amzn.to/39d0KdP
Digital Multimeter: https://amzn.to/34WbVoa
Vero Board / stripboard: https://amzn.to/39nL9Zg
Soldering iron kit: “best” You guys should definitely purchase this: https://amzn.to/2PVwexF
Solder wire: https://amzn.to/2QlOvTS
Wire Stripper: https://amzn.to/353tYJa
PCB small portable drill machine: https://amzn.to/2MvQqnx
Please Note: these are affiliate links. I may make a commission if you buy the components through these links. I would appreciate your support in this way!
What is a Solenoid Valve?
A Solenoid valve is basically an Automatic Valve which is electrically operated and thus removes the need for an Operator or an engineer or any other person to operate this valve manually. Regardless of the type and size of the Solenoid valve, the basic working principle of all the solenoid valves is exactly the same. The difference can be in terms of Voltage and the coil current needed to energize the coil of the solenoid valve.
In the Market, we have two types of solenoid valves
- Normally Open type Solenoid Valve
- Normally Closed type Solenoid Valve.
In Normally open type Solenoid Valve, the valve opening is open by default and when the voltage is applied the valve shut down. While in the normally closed type Solenoid Valve, the Valve opening is closed by default. When the voltage is applied the valve is opened. So by applying the voltage the state of the Solenoid valve can be changed from Open to Close or from Close to Open.
The type of solenoid valve as you can see is the Normally closed type, while in the market normally open type solenoid valves are also available. The normally closed type solenoid valve gets open when powered up.
As you can see it has two terminals, Its basic working principle is just like a relay, as in the case of a relay when we connect GND and 12v as you know there are power supply coil pins in relay the relay operates similarly solenoid valve has also two coil pins and when these terminals are connected with GND and 12 volts the solenoid valve can be operated and thus can be turned ON or Turned Off depending on the type of the Solenoid Valve.
for automatically controlling the solenoid valve we will need to make a driver circuit for this. we can control this solenoid valve using a transistor, A relay, A MOSFET, etc. you can select the transistor relay or MOSFET, etc its depends on the solenoid valve coil current, which is needed to energize the solenoid valve coil.
first of all, we find the coil resistance, for this use a digital multimeter, set it on resistance and connect one test lead of the digital multimeter with one terminal and another test lead with another terminal. we know that solenoid valve needs 12v but the coil resistance is15.6 ohm’s.
so v = 12v
now using the Ohm’s law
v = I R
we can find the current
I = V / R
so i = 12 / 15.6
i = .769 Amps
which is equals to 769 mA.
so from this value now you can decide, whether we need to use a transistor, MOSFET or a relay. we can use any of these three to control this solenoid valve. if you want to use a transistor or a MOSFET, make sure that the collector current or Drain current is greater than 769mA. keeping in mind the ambient temperature and other factors select a transistor or MOSFET higher than this value. but I will be using a relay. because it’s cheap and has no heat losses and another advantage of using a relay is that, it provides isolation.
This is a 12v SPDT type relay. SPDT stands for single pole double throw from Arduino or any other controller you can not be controlled 12v relay directly. A 12-volt relay driver will need to control the circuit. form driver circuit we can control the relay throughs 5v signal. we can make a driver circuit only if we know about its coil pins, so first, let’s find the coil pins and then find the resistance.
r = .426K ohm
r = 426 ohms
voltage is already know
Voltage V = 12v as the relay I am using is a 12v relay
then using the Ohm’s law
V = I R
we can find the current
I = V / R
i = 12 / 426
i = .028 Amps
which is equal to 28mA.
now we can use any NPN or PNP type transistor so far its collector current is greater than 28ma.
in the 2n2222 NPN transistor datasheet you will find that its collector current is much higher than the relay coil current. that’s why I selected the 2n2222n NPN transistor and that’s the reason I always use the 2n2222 NPN transistor for controlling the relays.
Automatic Water Tap Circuit Diagram:
This is the complete connection diagram, designed in cadsoft eagle As you can see one side of the relay coil is connected with 12v and the other side of the relay is connected to the collector of the 2n2222 transistor and the emitter of the 2n2222 transistor is connected with GND. with the help of this transistor, the gnd is connected and disconnected to the relay As it’s a BJT “bipolar junction transistor” and is a current-controlled device for that’s a 10k resistor is connected at the base of the 2n2222 transistor and will be connected with pin13 of the Arduino. for controlling the relay pin 13 of the Arduino will be used
common and normally open contacts of the relay is connected to the solenoid valve A GND from dc power jack is connected with one terminal of the solenoid valve, and the other terminal of the solenoid valve is connected with common of the 12v is connected with the normally open contact of the relay. So turning on and off this relay, we can turn on and turn off this solenoid valve.
Automatic Water Tap Programming:
int relay = 13; // relay is connected with pin 13
// this relay will be used to control the solenoid valve
int sensor = 4; // Infrared sensor is connected with pin4
int flag = 0; // this is a flag and it is changed from 0 to 1 and from 1 to 0 each time sensor is activated
int sflag = 0; // sensor flag which is used to monitor the state of the sensor when there is nothing infront of it.
if( (digitalRead(sensor) == LOW) && (flag == 0) && (sflag == 0) )
flag = 1;
sflag = 1;
if( (digitalRead(sensor) == LOW) && (flag == 1) && (sflag == 0) )
flag = 0;
sflag = 1;
if( (digitalRead(sensor) == HIGH)) // if there is nothing in front of the sensor
sflag = 0;
My name is Shahzada Fawad and I am a Programmer. Currently, I am running my own YouTube channel “Expertstech”, and managing this Website. My Hobbies are * Watching Movies * Music * Photography * Travelling * gaming and so on…