In this tutorial we will see how to assemble a gas leak detector alarm system with arduino nano. We will see a list of the electronic components to be used, the assembly of the circuit, the source code, and finally we will test the operation of the system. This project is ideal for use in sources near our home, where there is gas, such as a kitchen, stove or thermotanque.
Maybe you can be interested in projects in arduino, pic, robotics, telecommunications, subscribe to http://www.youtube.com/user/carlosvolt?sub_confirmation=1 lots of videos with complete source code and diagrams
Electronic components
mq2 gas sensor
Pin-Out sensor de gas Mq-2
Datasheet sensor MQ-2
Download–> MQ-2
Gas sensor (MQ2) is useful for gas leak detection (in home and industry). It can detect LPG, i-butane, methane, alcohol, hydrogen, smoke, etc. Based on its fast response time. measures can be taken as soon as possible. In addition, the sensitivity can be adjusted using a potentiometer (digital pin).
TECHNICAL SPECIFICATIONS
Operating Voltage: 5V DC
Fast
response and high sensitivity Detection range: 300 to 10000
ppm
Characteristic gas: 1000ppm, Isobutane Sensing resistance:
1KΩ 50ppm Toluene at 20KΩ in Response Time: ≤ 10s
Recovery time: ≤ 30s
Working temperature: -20°C~+55°C
Humidity: ≤ 95% RH
Ambient oxygen content: 21%
Consumes less than 150mA at 5V.
APPLICATIONS
Gas
Leak Detector Industrial Gas Detector
Arduino nano
The Arduino Nano is a small, complete and compatible board based on the ATmega328 (Arduino Nano 3.x). It has more or less the same functionality as the Arduino Duemilanove, but in a different package. It only lacks a DC power connector and works with a Mini-B USB cable instead of a standard one.
Microcontroller | ATmega328 |
Architecture | AVR |
Operating voltage | 5 V |
Flash memory | 32 KB of which 2 KB uses the bootloader |
SRAM | 2 KB |
Clock speed | 16 MHz |
Analog IN pins | 8 |
EEPROM | 1 KB |
DC current by I/O pins | 40 mA (I/O pins) |
Input voltage | 7-12 V |
Digital I/O pins | 22 (6 of which are PWM) |
PWM output | 6 |
Energy consumption | 19 mA |
PCB Size | 18 x 45 mm |
Weight | 7 g |
Pin diagram
Six 5 mm LED diodes of different colors
Six resistors of 1 Kohm
A 5-volt buzeer
Female pins (4 pins in total)
Male pins (In total 2)
Socket for the arduino nano
PCB
Download gerber file –> Gerber_MEDIDOR_DE_GAS_MQ-2
Circuit
Source code
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 |
int sensorMQ2=0; void setup(){ Serial.begin(9600);//Configuración de la velocidad del puerto serial de arduino a 9600 //Se configuraran los pines 2,3,4,5,6 y 7 como salidas //Del pin 2 al 6 van conectados a diodos led con su respectiva resistencia pinMode(2, OUTPUT); pinMode(3, OUTPUT); pinMode(4, OUTPUT); pinMode(5, OUTPUT); pinMode(6, OUTPUT); //Va conectado al Buzzer pinMode(7, OUTPUT); sensorMQ2=analogRead(A0);//Se lee el valor de la entrada analógica A0 donde está conectado el sensor MQ2 while(sensorMQ2>80){ Serial.print("Esperando a que se estabilice el sensor MQ2 (valor menor a 80): ");//Se imprime su valor por el terminal serial sensorMQ2=analogRead(A0);//Se lee el valor de la entrada analógica A0 Serial.println(sensorMQ2);//Se imprime su valor por el terminal serial digitalWrite(2, HIGH); digitalWrite(3, HIGH); digitalWrite(4, HIGH); digitalWrite(5, HIGH); digitalWrite(6, HIGH); delay(500); digitalWrite(2, LOW); digitalWrite(3, LOW); digitalWrite(4, LOW); digitalWrite(5, LOW); digitalWrite(6, LOW); delay(500); } } void loop(){ sensorMQ2=analogRead(A0);//Se lee el valor de la entrada analógica A0 Serial.print("Valor del sensor MQ2: "); Serial.println(sensorMQ2);//Se imprime su valor por el terminal serial //Se compara el valor de la variable sensorMQ2 si se cumple apagará todos los led if(sensorMQ2<79){ digitalWrite(2, LOW); digitalWrite(3, LOW); digitalWrite(4, LOW); digitalWrite(5, LOW); digitalWrite(6, LOW); digitalWrite(7, LOW); } //Se compara el valor de la variable sensorMQ2 si se cumple encenderá el led en el pin 2 if(sensorMQ2>80){ digitalWrite(2, HIGH); digitalWrite(3, LOW); digitalWrite(4, LOW); digitalWrite(5, LOW); digitalWrite(6, LOW); digitalWrite(7, LOW); } //Se compara el valor de la variable sensorMQ2 si se cumple encenderá el led en el pin 2 y 3 if(sensorMQ2>120){ digitalWrite(2, HIGH); digitalWrite(3, HIGH); digitalWrite(4, LOW); digitalWrite(5, LOW); digitalWrite(6, LOW); digitalWrite(7, LOW); } //Se compara el valor de la variable sensorMQ2 si se cumple encenderá el led en el pin 2, 3 y 4 if(sensorMQ2>160){ digitalWrite(2, HIGH); digitalWrite(3, HIGH); digitalWrite(4, HIGH); digitalWrite(5, LOW); digitalWrite(6, LOW); digitalWrite(7, LOW); } //Se compara el valor de la variable sensorMQ2 si se cumple encenderá el led en el pin 2, 3, 4, y 5 if(sensorMQ2>200){ digitalWrite(2, HIGH); digitalWrite(3, HIGH); digitalWrite(4, HIGH); digitalWrite(5, HIGH); digitalWrite(6, LOW); digitalWrite(7, LOW); } //Se compara el valor de la variable sensorMQ2 si se cumple encenderá el led en el pin 2, 3 ,4 ,5, 6 y el buzzer if(sensorMQ2>240){ digitalWrite(2, HIGH); digitalWrite(3, HIGH); digitalWrite(4, HIGH); digitalWrite(5, HIGH); digitalWrite(6, HIGH); digitalWrite(7, HIGH);//Se actica el buzzer } delay(100);//pequeño retardo antes de comenzar de vuelta } |
RECOMMENDED VIDEO