Arduino MQ137 PPM Sensor
Intro: Arduino MQ137 PPM Sensor
These sensors are electrochemical and vary their resistance when exposed to certain gases, internally it has a heater in charge of increasing the internal temperature and with this the sensor can react with the gases causing a change in the value of the resistance. The heater depending on the model may need a voltage between 5 and 2 volts, the sensor behaves like a resistor and needs a load resistance (RL) to close the circuit and with this make a voltage divider and be able to read it from a microcontroller.
Due to the heater it is necessary to wait for a warm-up time for the output to be stable and have the characteristics that the manufacturer shows in its datasheet, said time depending on the model can be between 12 and 48 hours.
In the market, MQ sensors are usually found in modules, which simplifies the connection part and facilitates its use, it is enough to feed the module and start reading the sensor, these modules also have a digital output which internally works with a comparator and with the help of a potentiometer we can calibrate the threshold and thus be able to interpret the digital output as presence or absence of gas.
NOTE: THIS SENSOR WILL HEAT A LITTLE
Credit: https://www.jayconsystems.com/tutorials/gas-sensor...
Calculations
This is a Work in progress, update Soon
Take a look and suscribe:
Promo Video:
STEP 1: Materials
Materials:
1 Arduino Uno
1 Oled Display 128 x 32 i2c Version
2 2.2k Ohm Resistors
1 Trimpot 100K Ohm
1 MQ-137 Sensor
1 RGB LED
Softwares:
https://www.arduino.cc/en/Main/Software
Librarys:
STEP 2: Calculations
We can derive a formula to find RS using Ohm's Law:
V = I x R
Which in our circuit is equal
to: I = VC / (RS+RL) RL=47kΩ
Ro: sensor resistance in the clean air.
Rs: sensor resistance at various concentrations of gases.
Then RS = [(VC x RL) / VRL] - RL
This formula will help us find the values of the sensor resistance for different gases. From the graph, we can see that the resistance ratio in fresh air is a constant:
RS / R0 = 2.6 ppm Fig. 3.
To calculate R0 we will need to find the value of the RS in fresh air.
This will be done by taking the analog average readings from the sensor and converting it to voltage.
Then we will use the RS formula to find R0. We will show you how to do this in the Arduino IDE after the wiring setup.
The scale of the graph is log-log. This means that in a linear scale, the behavior of the gas concentration with respect to the resistance ratio is exponential. The data for gas concentration only ranges from 10 ppm to 1000 ppm. Even though the relation between resistance ratio and gas concentration may seem linear, in reality, it is not. First of all, we will treat the lines as if they were linear. This way we can use one formula that linearly relates the ratio and the concentration. By doing so, we can find the concentration of a gas at any ratio value even outside of the graph’s boundaries.
The formula we will be using is the equation for a line, but for a log-log scale. The formula for a line is:
y = mx + b Where:
y: X value
x: X value m: Slope of the line
b: Y intercept
For a log-log scale, the formula looks like this:
log(y) = m*log(x) + b
Note: the log is base 10.
Okay, let’s find the slope. To do so, we need to choose 2 points from the graph.
The formula to calculate m is the following:
y = mx + b where:
value of x: X
value of m: Slope of line
b: Y intercepcion Point Graph (20,1.2) y (40,1)
m = [log(y) - log(y0)] / [log(x) - log(x0)]
m = log(1/1.2) / log(40/20)
m = -0.26303440583
Now for (30,1.1) log(y) = m*log(x) + b b = log(y) - m*log(x) b = log(1.1) - (-0.26303440583)*log(30)
b = 0.42992639673
Where: on the air RS / R0 = 3.6 R0 = 2.19
If you are not sure how logarithms work, you can refer to this link:http://www.rapidtables.com/math/algebra/Logarithm...
All credit:
STEP 3: Mounting
If You dont have the means to build a PCB Here i left the Fritzing Sketch
you want to reach the 100% of this project please visit and watch my tutorials(Soon):
www.youtube.com/user/josexers
STEP 4: Programming: First Steps
The first step that must be done to calculate R0, how we achieve this with a Sub Program called CAlc_R0 which is attached.
At first we uploas this sketch, and we wil get a serial responce from it.
We take note of this Value, IT'S VERY IMPORTANT!!
it's NOT A FIXED VALUE! it depends of the ambient
Now... we update some values in our pmain program:
int gas_sensor = A0; //Sensor pin
float m = -0.263; //Slope
float b = 0.42; //Y-Intercept
float R0 = 2.19; //Sensor Resistance in fresh air from previous code
STEP 5: 3D Printing
Here i left the files you need to print the box of our Project, it was made in Autosesk 123D Design.
Here is my Thingiverse Page:
https://www.thingiverse.com/thing:2637529
STEP 6: Extra Content
Notice that you can Add some more features to this sensor, such as RS-485 Modbus already mounted Compatible Library.
Also Notice that there is a RELAY OUTPUT, that we can use as a safety switch.
Also a JAva made Software its Compatible, comming soon.
STEP 7: ANDROID APP
This is an extra.
You can also Monitor how the sensor is reading Ammonia.
I used the MIT APP INVENTOR2
19 Comments
martyacude 3 years ago
mohamedamine 2 years ago
jmorles 3 years ago
108b32257 2 years ago
I'm reading the Ro and I'm getting negative values,is this normal?
WesleyJ11 5 years ago
I'm reading the Ro and I'm getting negative values, I made the cable change, the mq137 sensor, the mega, I left 24 hours reading and I still get negative values.
jmorles 3 years ago
jmorles 5 years ago
Mortenm7 5 years ago
R0 = -3.90
R0 = -3.90
R0 = -3.91
R0 = -3.91
...
1029838713 5 years ago
jmorles 5 years ago
yaksh 6 years ago
Hats off
S. RegitaC 6 years ago
hey i'm still confused how to find R0 value
is the R0 value is the converted analog average readings to the voltage?
jmorles 6 years ago
yes, it is a calculated value using the analog reading.
tavobachi 6 years ago
Thanks for the tutorial!! Where did you get your sensor from? And on Step 6: Extra Content on the "Y" axis says 0-100ppm, but the values go from 1000 to 8000. Is it because of accuracy of the sensor?
jmorles 6 years ago
yes it is, but you must be careful, read the sensor specs first
RAJXDAVIEL 6 years ago
how do we take Ro value from graph
jmorles 6 years ago
Ro is measured by anoter sketch, Step 4
ianmazzu 7 years ago
Nide done dude!
DIY Hacks and How Tos 7 years ago
Looks good. You should enter this into the Arduino contest that is currently running.