Академический Документы
Профессиональный Документы
Культура Документы
Live in a Safe
Environment.
By Manoj BR
http://www.instructables.com/member/Manoj+BR
http://www.instructables.com/id/Arduino-Air-Monitor-Shield-Live-in-a-Safe-Environm/
Table of Contents
Table of Contents 2
Introduction 3
Step-1 Gather Parts!!!!!! 4
Step-2 Deep Into the MQ Gas Sensors. 8
Step-3 Making and Calculating. 12
Step-4 The Code...... 22
Step-5 It Works!!!!!!!! 26
Arduino_Air_Monitor_Shield__Live_in_a_Safe_Environment_ 2
Introduction
Hello,
In this Instructabe I am going to make a Air monitoring shield for arduino. Which can
sense LPG leakage and CO2 concentration in our atmosphere.
And also beeps a buzzer turns on LED and the exhaust fan whenever LPG is detected or the concentration of CO2 increases.
As this was made to be work in home it does not need to be accurate, but it should be somewhat meaning full and should be suited for our
application.
As I was using this to turn on the exhaust fan when there was any LPG gas leakage or increase of CO2 and other harmful gases level. This was
to protect the family members health condition and prevent dangers that can be caused by leakage of LPG gas.
let's get started.
Arduino_Air_Monitor_Shield__Live_in_a_Safe_Environment_ 3
Step-1 Gather Parts!!!!!!
Gather these parts:
Main parts
1. Arduino Uno.
2. 16x2 lcd display.
3. MQ2.
4. MQ135.
5. RELAY 12v (current rating according to
your exhaust fan's specifications).
6. 12 volts power supply (for relay module).
Common parts
Arduino_Air_Monitor_Shield__Live_in_a_Safe_Environment_ 4
Arduino_Air_Monitor_Shield__Live_in_a_Safe_Environment_ 5
Arduino_Air_Monitor_Shield__Live_in_a_Safe_Environment_ 6
Arduino_Air_Monitor_Shield__Live_in_a_Safe_Environment_ 7
Step-2 Deep Into the MQ Gas Sensors.
Lets get to know about the MQ series gas sensors.
MQ series gas sensors have 6 pins, in which 2 of them is heaters and other 4 of them are sensor pins, whose resistance depends on the
concentration of the various gases according to their sensitive layer.
Heater pins H1, H2 are connected to 5 volts and ground( Polarity doesn't matters).
Use any one either A or B .( in schematic both are used, it is not required ).
connect A1(or B1) to 5 volts and A2(or B2) to RL (which is connected to the ground).
A2(or B2) is the analog output which should be connected to the analog input of the Arduino.
As the resistance of the sensor pins varies with change the concentration of gases, the voltage across the RL changes which is the analog input
for the arduino.
By analysing the graph of the sensors given in the datasheet we can convert that analog reading into concentrations of the gases .
These sensors need to be heated for 24 hours to 48 hours to get a stabilised readings .( the heating time is shown as pre-heat time in the
datasheet )
Accuracy can not be achieved without proper calibration , but for our application it is not needed.
https://www.google.co.in/url?sa=t&rct=j&q=&esrc=s&...
https://raw.githubusercontent.com/SeeedDocument/Gr...
MQ2:
MQ135:
Arduino_Air_Monitor_Shield__Live_in_a_Safe_Environment_ 8
Arduino_Air_Monitor_Shield__Live_in_a_Safe_Environment_ 9
Arduino_Air_Monitor_Shield__Live_in_a_Safe_Environment_ 10
Arduino_Air_Monitor_Shield__Live_in_a_Safe_Environment_ 11
Step-3 Making and Calculating.
Build your circuits according to the schematics.
In my circuits you can see the modules of gas sensors . I modified their circuitry to the above schematic.
leave the sensors to heat for 24 hours to 48 hours according to the pre heat time. while that time lets analyse the graph of the MQ135 to get the
equation for CO2.
log(y) = m*log(x)+c
where,
m is the slope .
c is the y intercept .
m= log(Y2)-log(Y1) / log(X2-X1)
m=log(Y2/Y1) / log(X2/X1)
by taking the points on the CO2 line the average slope of the line is -0.370955166.
c= log(Y)- m*log(x)
considering m value in the equation and taking the X and Y values from the graph.
The equation is :
log(Rs/Ro) = m * log(ppm) + c
log(ppm) = [log(Rs/Ro) - c] / m
ppm = 10^{[log(Rs/Ro) - c] / m}
Calculating R0:
we know that ,
where,
in our case,
V =5 volts
therefore , Rs = RT-RL
RT= V*RL/VRL.
and Rs = (V*RL/VRL)-RL
Arduino_Air_Monitor_Shield__Live_in_a_Safe_Environment_ 12
we know that ,
log(Rs/Ro) = m * log(ppm) + c
Rs/Ro = 0.6230805382.
use the code " to get Ro " and also note the value of V2( in fresh air).
and also note down the value of R0.
I programmed in such a way that the Ro, V1 and V2 are displayed both on serial monitor and LCD.(Because I don't want to keep my PC stay on
until the readings stabilise ).
Arduino_Air_Monitor_Shield__Live_in_a_Safe_Environment_ 13
Arduino_Air_Monitor_Shield__Live_in_a_Safe_Environment_ 14
Arduino_Air_Monitor_Shield__Live_in_a_Safe_Environment_ 15
Arduino_Air_Monitor_Shield__Live_in_a_Safe_Environment_ 16
Arduino_Air_Monitor_Shield__Live_in_a_Safe_Environment_ 17
Arduino_Air_Monitor_Shield__Live_in_a_Safe_Environment_ 18
Arduino_Air_Monitor_Shield__Live_in_a_Safe_Environment_ 19
Arduino_Air_Monitor_Shield__Live_in_a_Safe_Environment_ 20
Arduino_Air_Monitor_Shield__Live_in_a_Safe_Environment_ 21
Step-4 The Code......
here is the link to download codes from GitHub.
https://github.com/ManojBR105/Arduino-Air-Monitor
RS_CO2 is the the RS of the MQ135 in 400 ppm CO2 which is the current concentration of the CO2 in Atmosphere.
we start by defining the connections of the buzzer, led, MQ2, MQ135, Relay.
Next in setup, we define whether the connected components are input or output and also there states(i.e, high or low).
Then we begin LCD display and make it to display as "Arduino Uno Air Monitor Shield" for 750 milli seconds with a beep of buzzer and LED.
In loop
We first define all the terms that we use in the formula for calculation that I said in previous step.
Define your R0 value in this section.(which I said to note down while running the previous code).
using " if " function we use the threshold limit for the ppm value which I have used as 600 ppm.
and also for the MQ2 voltage we use " if " function to set the threshold limit for it.
we make the buzzer , led, relay to go high for 2 seconds when the if function is satisfied ad also make the LCD to display LPG as Detected when
MQ2's voltage is higher than the threshold limit.
Define your threshold limit for MQ2's voltage that you noted down during the previous code as V2.(set this slight higher than that value).
After this we will define " else " function and delay the loop for 1 second.
Instead of using Delay to set the output high for 2 seconds in the if function it is good to use a simple timer.
If anybody could modify the delay into timer in the code, you are always welcomed and let me know that in the comment section.
Arduino_Air_Monitor_Shield__Live_in_a_Safe_Environment_ 22
Arduino_Air_Monitor_Shield__Live_in_a_Safe_Environment_ 23
Arduino_Air_Monitor_Shield__Live_in_a_Safe_Environment_ 24
Arduino_Air_Monitor_Shield__Live_in_a_Safe_Environment_ 25
Step-5 It Works!!!!!!!!
Here is the video to demonstrate that it is working.
sorry I could not show the relay in the video.
you can notice that the Concentration of CO2 increases madly because the gases released from the lighter also poses effect on the MQ135
which is sensitive to other gases also but don't worry it will come back to normal after few seconds.
https://youtu.be/LQQwnMn-uZ4
Arduino_Air_Monitor_Shield__Live_in_a_Safe_Environment_ 26