Go Down

### Topic: MQ-7 gas sensor (Read 3095 times)previous topic - next topic

#### Virginia

##### Apr 14, 2011, 09:40 amLast Edit: Apr 14, 2011, 12:42 pm by Virginia Reason: 1
Hi all!I have been reading a lot about this sensor in internet and in the forum, but in fact, I still cannot make it work properly. After readint his webpage:
http://forum.sparkfun.com/viewtopic.php?f=14&t=18447
I decided to supply 5V during 120sec and 0V during 180 sec. Then I take readings during the last 20 sec of the 0V period and average them. I use a 10K RL, my problem is that I get pretty stable readings around 400 (can read from 0-4095), which is too low and results in Rs of aprox 90k, and plus, as I do more readings this values go decreasing, so Rs go increasing. During the 5V period I get higher readings, around 1200, but not so stabel. Plus, just by reading the satasheet I have no clue how to conevrt this tho ppm, asit says 100ppm for CO in the clean air, and as I was reading in wikipedia and other sites, limit of safety is 50ppm. Also, I do not understand if which values can get the Rs. The 20-200k is for 100ppm or is from 10-10000ppm? I hope someone can help me with this. My code is as follows, thanks!
Code: [Select]
`  if (cont_GasV==120){           //PUT GAS INPUT TO 1.4V DURING18sec        Gas_val=0.0;      P4OUT&=~BIT6;             //SETTING OUT AS 1 MAKES TRANSISTOR GIVE 0V            //  P7OUT&=~0x08;     }      else if (cont_GasV>=280&&cont_GasV<=299){      ADC12IE = 0x01;                           // Enable ADC12IFG.3      halAdcStartRead();      Gas_val=SavedADC12MEM0+Gas_val;        // Store the sampled data      }     else if (cont_GasV==300){    //PUT GAS INPUT TO 5.0V DURING 120sec       cont_GasV=0;        P4OUT|=BIT6;                  //SETTING OUT AS 0 MAKES TRANSISTOR GIVE +5V        Gas_val=Gas_val/20.0;         Gas_val=(5.0*Gas_val)/4095.0;    //COMPUTE VRL        Gas_val=10.0*((5.0-Gas_val)/Gas_val);               //COMPUTE RS       char gas[20];      sprintf(gas,"GAS: %.4f ",Gas_val);      HalLcdWriteString(gas,8);     }`

#### robtillaart

#1
##### Apr 14, 2011, 11:50 am
Please modify your post, select the code and press the # button. Also post the whole code if possible.

Rob Tillaart

Nederlandse sectie - http://arduino.cc/forum/index.php/board,77.0.html -
(Please do not PM for private consultancy)

#### Virginia

#2
##### Apr 14, 2011, 01:07 pm
Thnaks! I did not know how to do that, so is done!
Regarding the previous results, I realized that I was in fact NOT using a 10K resistor, but now I modified it and I am getting more logic results. Anyway, my ADC output in the 0V phaseis around 1000, that gives me about 27k of Rs. Anyway, this seems to be increasing with time (ADC decreasing). Still no idea why and also how to convert to ppm

#### robtillaart

#3
##### Apr 14, 2011, 01:10 pm
Thanks,

Could you please post the whole sketch as this snippet makes too little sense for me, sorry ;(
Rob Tillaart

Nederlandse sectie - http://arduino.cc/forum/index.php/board,77.0.html -
(Please do not PM for private consultancy)

#### Virginia

#4
##### Apr 14, 2011, 01:22 pm
Sorry, in fcat my code is quite huge with several libraries, as is part of a bigger project. I am in fcat developing it with a texas chip, so it may differ a bit. What I do is basically each second (and taking into account that VH=5V at the beggining):

Code: [Select]
`read adc inputcont++if cont=60sec {  VH=0V;}else if cont >140 and cont<149  //store data at the end of the 90 sec cool period  {store ADC;}else if cont=150sec (this is 60+90) { VH=5V;  averagesamples=store ADC/10;  Gas_val=(5.0*Gas_val)/4095.0;    //COMPUTE VRL   Gas_val=10.0*((5.0-Gas_val)/Gas_val);               //COMPU}`

hope this can help to understand

#### robtillaart

#5
##### Apr 14, 2011, 07:21 pm

where do you make the ten samples in the code?
Rob Tillaart

Nederlandse sectie - http://arduino.cc/forum/index.php/board,77.0.html -
(Please do not PM for private consultancy)

#### Virginia

#6
##### Apr 15, 2011, 08:53 am
The 10 samples I make them from 140 to 140, I go on storing them (summing ) in the same variable

#### robtillaart

#7
##### Apr 16, 2011, 12:34 am
if i understand the code it is this part:
Code: [Select]
`if cont >140 and cont<149  //store data at the end of the 90 sec cool period  {store ADC;}`
assuming that store ADC does the summing it will be called when cont = { 141,142,143,144,145,146,147,148 } so eight times. and a bit later you divide it by ten. that will make your outcome lets say 20% smaller than it should be, or said differently, the real average is 25% greater.
Code: [Select]
`if cont > 139 and cont < 150  //store data at the end of the 90 sec cool period{  store ADC;}`
That 20% smaller value goes into the rest of your formula so it will be incorrect too

Rob Tillaart

Nederlandse sectie - http://arduino.cc/forum/index.php/board,77.0.html -
(Please do not PM for private consultancy)

#### vhenamae

#8
##### Nov 05, 2011, 04:17 pm
Hi guys..
can somebody help me how to convert the analog out to ppm values?

Go Up

Please enter a valid email to subscribe

To complete the subscription, please click the link in the email we just sent you.

Thank you for subscribing!

Arduino
via Egeo 16
Torino, 10131
Italy