Gas leakage detector and Automatic Solenoid Valve shut down using Arduino and MQ-2 Sensor

(Last Updated On: October 26, 2019)

solenoid valve

Description:

Arduino Gas leakage detector and Automatic Solenoid Valve shut down- In this tutorial, you will learn how to make a gas leak detector and automatic valve shut down the system using Arduino, MQ-2 sensor, relay module, and Solenoid valve? Then watch this tutorial from start to the very end. In this tutorial, we will be covering how to find the solenoid valve coil resistance, How to perform the relay driver circuit design calculations to make our own relay module, which can be then used for controlling the solenoid valve.  Let’s get started.

Watch Video: Click Here


 The components and tools used in this project can be purchased from Amazon, the components Purchase links are given below:

Arduino Uno: https://amzn.to/2tVz1vu
Mega 2560: https://amzn.to/2ze1kdu
solenoid valve: https://amzn.to/2NyoD50
smoke sensor MQ-2: https://amzn.to/2Mv1wai
lm7805 Voltage Regulator: https://amzn.to/2IZEl5x
330-ohm resistors pack: https://amzn.to/2NtlAeh
5v 2A adaptor: https://amzn.to/2GsNfcw
2n2222 NPN transistors: https://amzn.to/2EmXsIb
10k Resistor: https://amzn.to/2KTd6OW
lm7805 Voltage Regulator: https://amzn.to/2IZEl5x
330-ohm resistors pack: https://amzn.to/2NtlAeh
female DC power jack socket: https://amzn.to/2KEo1gt
470 UF capacitors: https://amzn.to/2xDCOzf
5×7 cm Vero board: https://amzn.to/2OHGbvn
female headers: https://amzn.to/2zqmtiJ
connection wires: https://amzn.to/2DpBuW7
Super Starter kit for Beginners: https://amzn.to/2KJvmKG
Jumper Wires: https://amzn.to/2KMoVXs
Bread Board: https://amzn.to/2MS4q8X
12v Adaptor: https://amzn.to/2Ntr6h1
PCB plate: https://amzn.to/2IUwpCt
Variable Supply: https://amzn.to/2MT4Qfj
Digital Multimeter: https://amzn.to/2Nvft9i
Vero Board / stripboard: https://amzn.to/2MTf9jD
Soldering iron kit: “best” You guys should definitely purchase this: https://amzn.to/2zfoNuJ
Solder wire: https://amzn.to/2ufUMWf
Wire Stripper: https://amzn.to/2KOqxfU
wirecutter: https://amzn.to/2ucIq14
PCB small portable drill machine: https://amzn.to/2Nu62XF

*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?

gas leakage detector

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 any Gas leakage detector project a Solenoid Valve plays an important role, as it provides the automatic valve shut down.


In the Market, we have two types of solenoid valves

  1. Normally Open type Solenoid Valve
  2. 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 the 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 get’s opened when energized.

solenoid valve

As you can see it has two coil terminals, its basic working principle is just like a relay, as in the case of a relay when we connect GND and 12v from the power supply with the relay coil pins. the relay operates, similarly, the solenoid valve has also two coil terminals, 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.


To control this solenoid valve automatically we will need to make a driver circuit for this. You can control this solenoid valve using a transistor, a relay, A MOSFET, etc. The selection of the transistor, relay or MOSFET, etc depends on the solenoid valve coil current, which is needed to energize the solenoid valve coil. Let’s say we want to control this solenoid valve using a transistor or a MOSFET.

solenoid valve

First, 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. The coil resistance is 15.6 ohm’s, and we already know this solenoid valve needs 12v.

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 we 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. However, I will be using a relay. Because it is cheap and has no heat, losses and another advantage of using a relay are that, it provides isolation.


solenoid valve

This is a 12v SPDT type relay. SPDT stands for single pole double throw.  A 12v relay cannot be controlled directly using the Arduino board or any other controller. We need a driver circuit to control a 12-volt relay. Then using the driver circuit we can control the relay through a 5v signal. We can make a driver circuit only if we know about its coil pins, so first, let us 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 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.

If you check the datasheet of the 2n2222 NPN transistor you will find that its collector current is much greater than the relay coil current. That is why I selected the 2n2222n NPN transistor and that is the reason I always use the 2n2222 NPN transistor for controlling the relays.


Circuit Diagram of the Gas leakage detector:

solenoid valve

This is the complete connection diagram, designed in Cadsoft eagle if you want to learn how to make schematics and PCB’s then watch my tutorials. As you can see one side of the relay coil is connected with 12v and the other side of the relay coil is connected to the collector of the 2n2222 transistor and the emitter of the 2n2222 transistor is connected with GND. So the GND to the relay coil is connected and disconnected with the help of this transistor. As it’s a BJT “bipolar junction transistor” and is a current-controlled device that’s why a 10k resistor is connected at the base of the 2n2222 transistor and will be connected with pin13 of the Arduino. So Arduino pin13 will be used to control this relay.

A solenoid valve is connected with relay common and normally closed contacts. A GND from dc power jack is connected with one terminal of the valve, and the other terminal of the valve is connected with the common of the relay and normally open contact of the relay is connected with 12v. So turning on and off this relay, we can turn on and turn off this valve.

As you can see the Vcc of the MQ-2  Sensor module will be connected with Arduino’s 5v, GND will be connected with the Arduino’s GND and its A0 pin will be connected with Arduino’s analog pin A1.


Programming of the Gas leakage detector:

Watch Video Tutorial:

 

Another Gas Leakage Detector Related Project:

Arduino Gas leakage detection and SMS alert MQ-2 sensor

 

Arduino gas sensor MQ2, Smoke Detector, Programming & Circuit

 

 

Recommended For You

About the Author: Engr Fahad

My name is Shahzada Fahad and I am an Electrical Engineer. I have been doing Job in UAE as a site engineer in an Electrical Construction Company. Currently, I am running my own YouTube channel "Electronic Clinic", and managing this Website. My Hobbies are * Watching Movies * Music * Martial Arts * Photography * Travelling * Make Sketches and so on...

Leave a Reply

Close