Introduction: 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
This is a Work in progress, update Soon
Take a look and suscribe:
Teachers! Did you use this instructable in your classroom?
Add a Teacher Note to share how you incorporated it into your lesson.
Step 1: 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
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...
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):
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:
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
Participated in the
Arduino Contest 2017