Go Down

Topic: Using the MQ136 Sensor (Read 1 time) previous topic - next topic

FutureTense

Oct 12, 2018, 11:17 pm Last Edit: Oct 12, 2018, 11:20 pm by FutureTense
I just received a SainSmart MQ136 Semiconductor Sensor for Hydrogen Sulfide, which is a sensor attached to a little board.  This is different from a lot of the gas sensors I've seen online that don't come with the board.  I'm not exactly what this is called and what purpose it serves, but I guess it contains things to make it easier to use.

It also has a potentiometer on the back, but since I can't find a datasheet, I'm not exactly sure what it is for.  It has 4 pins and I'm assuming they are for:

G       Ground
AO     Analog Output
DO     Digital Output
V       Voltage

I'm trying to measure when hydrogen sulfide (stinky!) is detected.  The higher the concentration, the more an LED blinks.  Besides trying to find out what the pot is for, I'm trying to find out the high and low "temperature" ranges this produces so I can adjust my code to blink slowly when there is less HS detected, and more when it is higher.  I initially built this with a regular pot in place of the sensor and it worked nicely.  When I run this now, I'm getting analog readings of around 420, but it never changes much in either direction.  Maybe 395-430.

Any idea on how I can find the datasheet for this and understand the AO output (min and max values)?  I've removed the LED code for brevity.

Code: [Select]

int analog_MQ136=A5;  //MQ136 Hydrogen Sulfide sensor

// the setup routine runs once when you press reset:
void setup() {                
  // initialize the digital pin as an output.
  pinMode(analog_MQ136, INPUT);
  Serial.begin(9600);
}

// the loop routine runs over and over again forever:
void loop() {
  int x;

  x=analogRead(analog_MQ136);  //read the sensor
 

  Serial.print("Temp:");
  Serial.println(x);
  delay(1000);
}

wvmarle

You even tried Bing! You must be really desperate.

There's a pot.
The description on the Sainsmart page mentions that the load resistance is "adjustable" - making that the only candidate for that pot, and the pot the only candidate for this "adjustable" resistance.
The MQ136 data sheet is easy to find - do some trace following on the PCB. Quite sure that pot is the adjustable load resistance.
I do agree that it's not good of Sainsmart to not add a proper datasheet/manual with their products.
Quality of answers is related to the quality of questions. Good questions will get good answers. Useless answers are a sign of a poor question.

jremington

Quote
Any idea on how I can find the datasheet for this and understand the AO output (min and max values)?
MQ136 data sheet.

The "A0 output" doesn't mean much unless you have (1) done a "burn in" of the required length, up to 168 hours for a sensor that has been stored for months and (2) calibrated the output using a known concentration of H2S gas in dry air.

However, the output can alert you to changes in the H2S concentration -- or possibly, some other gas (including humidity changes), as these sensors are not very discriminating.

Here is a great general tutorial on using the MQ sensors.

FutureTense

MQ136 data sheet.

The "A0 output" doesn't mean much unless you have (1) done a "burn in" of the required length, up to 168 hours for a sensor that has been stored for months and (2) calibrated the output using a known concentration of H2S gas in dry air.

However, the output can alert you to changes in the H2S concentration -- or possibly, some other gas (including humidity changes), as these sensors are not very discriminating.

Here is a great general tutorial on using the MQ sensors.
I assume all I need to do a burn in is to have the sensor powered up for the burn in period, correct?

    x=analogRead(analog_MQ136);  //read the sensor
   
What unit is x?  e.g. assuming the sensor is burned in, and operating conditions are 20C and 55RH, if the code above is ran and x = 429, what is the ppm of H2S the sensor is detecting?  I suspect I need something from here.



Unfortunately the DS has a few problems, like the following  truncated text. 

Quote
NOTE: The change of Output voltage( △ Vs) is the difference value between VRL in test environment and
This leads me to beleive x is a delta voltage from the VRL.  Is the VRL based upon the the potentiometer setting and 5V? According to the DS the load resistance (Rl) is adjustable, and being the pot is the only adjustable component, how does one know what each setting on the pot is doing?  Is there a way to hook up my MM and know what's happening when I spin the wheel?


wvmarle

The result from analogRead() is a number in the range 0-1023, and has no units as such.

The only way to link this reading to an actual gas concentration is to calibrate the sensor using known concentrations.
Quality of answers is related to the quality of questions. Good questions will get good answers. Useless answers are a sign of a poor question.

jremington

Quote
The "A0 output" doesn't mean much unless you have (1) done a "burn in" of the required length, up to 168 hours for a sensor that has been stored for months and (2) calibrated the output using a known concentration of H2S gas in dry air.

FutureTense

#6
Oct 14, 2018, 10:49 pm Last Edit: Oct 14, 2018, 10:54 pm by FutureTense
Here is a great general tutorial on using the MQ sensors.
So that link led me to a video and to this site which has some pseudo calibration code based upon the graph in datasheet for the MQ2.  I was going to add a N2SCurve, however I can't figure out how they came up with those values for LPG, CO, and Smoke.

All of those gases have the same x value = 2.3 -- how did they get that from the graph?  I suppose if I could understand that I might be able to come up with their y values.  And then I could easily pick another point and find the slope.  Only then would I be able to repeat the procedure for H2S.

Code: [Select]

/*****************************Globals***********************************************/
float           LPGCurve[3]  =  {2.3,0.21,-0.47};   //two points are taken from the curve.
                                                    //with these two points, a line is formed which is "approximately equivalent"
                                                    //to the original curve.
                                                    //data format:{ x, y, slope}; point1: (lg200, 0.21), point2: (lg10000, -0.59)
float           COCurve[3]  =  {2.3,0.72,-0.34};    //two points are taken from the curve.
                                                    //with these two points, a line is formed which is "approximately equivalent"
                                                    //to the original curve.
                                                    //data format:{ x, y, slope}; point1: (lg200, 0.72), point2: (lg10000,  0.15)
float           SmokeCurve[3] ={2.3,0.53,-0.44};    //two points are taken from the curve.
                                                    //with these two points, a line is formed which is "approximately equivalent"
                                                    //to the original curve.
                                                    //data format:{ x, y, slope}; point1: (lg200, 0.53), point2: (lg10000,  -0.22)                                                    
float           Ro           =  10;                 //Ro is initialized to 10 kilo ohms


Here's the MQ2 graph so you don't have to switch back and forth:


jremington

#7
Oct 14, 2018, 11:50 pm Last Edit: Oct 14, 2018, 11:51 pm by jremington
Quote
All of those gases have the same x value = 2.3 -- how did they get that from the graph?
Good question. I saw that post some time ago, scratched my head and decided it was complete nonsense.

If you are interested in obtaining meaningful concentrations, you really do have to calibrate your sensor, using your setup, with a known gas mixture standard.

That does pose challenges, but you have no other options. If you live near a research university with a chemistry department, you can probably find someone willing to help.

FutureTense

I really just want the sensor to go off when it picks up N2S.  So if the cat poops, the wife farts, etc. then the Arduino goes into action.

FutureTense

I just realized something.  Right now I'm using an old Uno powered via USB.  The sensor requires 5V.  I just measured the rails and they are reporting 4.49.  Eventually I'm going to use one of of the mini ESB boards with WiFi which I think requires 5 or 3.3V.  I was hoping on plugging this into a wall wart.

Do I need to provide power to the Arduino and the sensor separately?

What are my options to keep this down to using one wall wart? 

wvmarle

5v wall wart, making use of the Arduino's built in regulator (assuming there is one, otherwise get a separate one).
Quality of answers is related to the quality of questions. Good questions will get good answers. Useless answers are a sign of a poor question.

FutureTense

Isn't .5V going to make a difference for the sensor?

wvmarle

That shouldn't be an issue.
Quality of answers is related to the quality of questions. Good questions will get good answers. Useless answers are a sign of a poor question.

Go Up