MQ-4 Sensor Curve

Hallo.

I used MQ-4 grafik from https://www.sparkfun.com/datasheets/Sensors/Biometric/MQ-4.pdf, but I need more detail information about CH4 Curve. Example : float LPGCurve[3] = {2.3,0.21,-0.47}; Anybody can help me to how finding the curve and calculate the points.

Thanks.

Thats a log-log scale.

excel tell me that ppm=1021*(rs/r0)^-2.7887

bases on theese values: rs/r0 ppm 1,8 200 1 1000 0,57 5000 0,44 10000

..arduino got thr pow-function (or use log)

Or you can use multimap - http://playground.arduino.cc/Main/MultiMap - and use interpolation

Dear Rob.

float CH4Curve[3] = {2.3, 1, -0.38};

I used from your calculate. log(200) for 2.3 and 1 for log 1000, but how the slope. That is true for my formula.

..use the simple formula from #1: ppm=1021*pow((rs/r0),-2.7887); The only job is to calculate the relative change in resistance, based on the analog value u read.

I try like this. that is true. please correct me when i am wrong.

void setup() { Serial.begin(9600); //Set serial baud rate to 9600 bps }

void loop() { int val; float ppm; val=analogRead(0);//Read Gas value from analog 0 //Serial.println(val,DEC);//Print the value to serial port ppm=1021*pow((1),-2.7887); Serial.println(ppm);

delay(500); }

after this on: val=analogRead(0);//Read Gas value from analog 0 // calcurate rs/ro..

We need to know: value of the serial resistor and the analogread value in 'clean' air. also need to know how this is connected: 5V->sensor->resistor->GND ? or 5V->resistor->sensor->GND ? Give us theese info, I'll show you how to go on.. addition: Sensor must be powed a looong time before reading the analog.. (>24 hours)

I try using this code. Please corrected of the algorithm.

define RL_VALUE (4.7)

void setup() { Serial.begin(9600); //Set serial baud rate to 9600 bps }

void loop() { int val; float ppm; float ro; float ratio; float rs; ro=10; //kOhm int i; val=analogRead(0);//Read Gas value from analog 0 //Serial.println(val,DEC);//Print the value to serial port //ppm=1021*pow((1),-2.7887); //calculate rs/ro

rs=((RL_VALUE * (1021 - val) / val)); ratio=rs/ro; //Serial.println(RL_VALUE); //Serial.println("\n"); Serial.println(ratio); Serial.println(" rs/ro"); Serial.println("\n"); ppm=1021*pow((ratio),-2.7887); Serial.println(ppm); Serial.println(" ppm"); Serial.println("\n");

delay(1000); }

I tried this one. (my sensor heated for 3 hrs only)

#define RL 4.7 //serial resistor
int val;
float ppm;
float r0=10; //10k = estimat for 1000ppm // datasheet says 10k..60k
// calibration in known concentration is needed !
float ratio;
float rs;
int i;

void setup()
{
  Serial.begin(9600); //Set serial baud rate to 9600 bps
}

void loop()
{
  val=analogRead(0);//Read Gas value from analog 0
  Serial.print("Raw\t");
  Serial.print(val);
  Serial.print("\t");
  rs=((RL * (1023 - val) / val));
  Serial.print("Rsensor\t");
  Serial.print(rs,0);
  Serial.print("\t");
  ratio=rs/r0;
  Serial.print("Rato\t");
  Serial.print(ratio,1);
  Serial.print("\t => ");
  ppm=1021*pow((ratio),-2.7887);
  Serial.print(ppm,0);
  Serial.println("\tppm");
  delay(1000);
}

This output.. Then introduced some drops of aceton 3cm away..:

Raw 40  Rsensor 116 Rato    11.6     => 1   ppm
Raw 40  Rsensor 116 Rato    11.6     => 1   ppm
Raw 40  Rsensor 116 Rato    11.6     => 1   ppm
Raw 41  Rsensor 113 Rato    11.3     => 1   ppm
Raw 42  Rsensor 110 Rato    11.0     => 1   ppm
Raw 42  Rsensor 110 Rato    11.0     => 1   ppm
Raw 42  Rsensor 110 Rato    11.0     => 1   ppm
Raw 41  Rsensor 113 Rato    11.3     => 1   ppm
Raw 40  Rsensor 116 Rato    11.6     => 1   ppm
Raw 41  Rsensor 113 Rato    11.3     => 1   ppm
.. aceton..: two drops onto paper 
Raw 54  Rsensor 84  Rato    8.4  => 3   ppm
Raw 117 Rsensor 36  Rato    3.6  => 28  ppm
Raw 206 Rsensor 19  Rato    1.9  => 180 ppm
Raw 262 Rsensor 14  Rato    1.4  => 429 ppm
Raw 256 Rsensor 14  Rato    1.4  => 393 ppm
Raw 330 Rsensor 10  Rato    1.0  => 1059    ppm
Raw 385 Rsensor 8   Rato    0.8  => 2050    ppm
Raw 398 Rsensor 7   Rato    0.7  => 2382    ppm
Raw 377 Rsensor 8   Rato    0.8  => 1867    ppm
Raw 404 Rsensor 7   Rato    0.7  => 2551    ppm
Raw 381 Rsensor 8   Rato    0.8  => 1957    ppm
Raw 369 Rsensor 8   Rato    0.8  => 1699    ppm
Raw 356 Rsensor 9   Rato    0.9  => 1456    ppm
Raw 271 Rsensor 13  Rato    1.3  => 487 ppm
Raw 200 Rsensor 19  Rato    1.9  => 162 ppm
Raw 190 Rsensor 21  Rato    2.1  => 136 ppm
Raw 212 Rsensor 18  Rato    1.8  => 199 ppm
Raw 290 Rsensor 12  Rato    1.2  => 632 ppm
Raw 199 Rsensor 19  Rato    1.9  => 159 ppm
Raw 160 Rsensor 25  Rato    2.5  => 76  ppm
Raw 143 Rsensor 29  Rato    2.9  => 53  ppm
Raw 162 Rsensor 25  Rato    2.5  => 79  ppm
Raw 183 Rsensor 22  Rato    2.2  => 120 ppm
Raw 216 Rsensor 18  Rato    1.8  => 212 ppm
Raw 242 Rsensor 15  Rato    1.5  => 319 ppm
Raw 241 Rsensor 15  Rato    1.5  => 315 ppm
Raw 235 Rsensor 16  Rato    1.6  => 287 ppm
Raw 243 Rsensor 15  Rato    1.5  => 324 ppm
Raw 257 Rsensor 14  Rato    1.4  => 399 ppm
Raw 242 Rsensor 15  Rato    1.5  => 319 ppm
Raw 308 Rsensor 11  Rato    1.1  => 801 ppm
Raw 304 Rsensor 11  Rato    1.1  => 760 ppm
Raw 278 Rsensor 13  Rato    1.3  => 537 ppm
Raw 317 Rsensor 10  Rato    1.0  => 899 ppm
Raw 264 Rsensor 14  Rato    1.4  => 441 ppm
Raw 226 Rsensor 17  Rato    1.7  => 249 ppm
Raw 270 Rsensor 13  Rato    1.3  => 480 ppm
Raw 300 Rsensor 11  Rato    1.1  => 721 ppm
Raw 328 Rsensor 10  Rato    1.0  => 1033    ppm
Raw 305 Rsensor 11  Rato    1.1  => 770 ppm
Raw 288 Rsensor 12  Rato    1.2  => 615 ppm
Raw 265 Rsensor 13  Rato    1.3  => 447 ppm
Raw 223 Rsensor 17  Rato    1.7  => 238 ppm
Raw 190 Rsensor 21  Rato    2.1  => 136 ppm
Raw 202 Rsensor 19  Rato    1.9  => 168 ppm
Raw 204 Rsensor 19  Rato    1.9  => 174 ppm
Raw 154 Rsensor 27  Rato    2.7  => 67  ppm
Raw 150 Rsensor 27  Rato    2.7  => 62  ppm
Raw 161 Rsensor 25  Rato    2.5  => 78  ppm
Raw 171 Rsensor 23  Rato    2.3  => 95  ppm
Raw 179 Rsensor 22  Rato    2.2  => 111 ppm
Raw 191 Rsensor 20  Rato    2.0  => 138 ppm
.. evapurated totally..
Raw 172 Rsensor 23  Rato    2.3  => 97  ppm
Raw 149 Rsensor 28  Rato    2.8  => 60  ppm
Raw 138 Rsensor 30  Rato    3.0  => 47  ppm
Raw 165 Rsensor 24  Rato    2.4  => 84  ppm
Raw 150 Rsensor 27  Rato    2.7  => 62  ppm
Raw 126 Rsensor 33  Rato    3.3  => 35  ppm
Raw 113 Rsensor 38  Rato    3.8  => 25  ppm
Raw 109 Rsensor 39  Rato    3.9  => 22  ppm
Raw 104 Rsensor 42  Rato    4.2  => 19  ppm
Raw 96  Rsensor 45  Rato    4.5  => 15  ppm
Raw 89  Rsensor 49  Rato    4.9  => 12  ppm
Raw 84  Rsensor 53  Rato    5.3  => 10  ppm
Raw 81  Rsensor 55  Rato    5.5  => 9   ppm
Raw 78  Rsensor 57  Rato    5.7  => 8   ppm
Raw 77  Rsensor 58  Rato    5.8  => 8   ppm
Raw 76  Rsensor 59  Rato    5.9  => 7   ppm
Raw 76  Rsensor 59  Rato    5.9  => 7   ppm
Raw 74  Rsensor 60  Rato    6.0  => 7   ppm
Raw 72  Rsensor 62  Rato    6.2  => 6   ppm
Raw 69  Rsensor 65  Rato    6.5  => 6   ppm
Raw 68  Rsensor 66  Rato    6.6  => 5   ppm
Raw 67  Rsensor 67  Rato    6.7  => 5   ppm
Raw 66  Rsensor 68  Rato    6.8  => 5   ppm
Raw 64  Rsensor 70  Rato    7.0  => 4   ppm
Raw 64  Rsensor 70  Rato    7.0  => 4   ppm
Raw 63  Rsensor 72  Rato    7.2  => 4   ppm
Raw 62  Rsensor 73  Rato    7.3  => 4   ppm

This Output I trying in the soil. every data sampling 5 minute. Open Clean air and Close Air.

Time ppm
5 206
10 199
15 199
20 196
25 230
30 206
35 219
40 189
45 183
50 177
55 189
60 189
65 196
70 196
75 165
80 174
85 168
90 189
95 189
100 199
105 165
110 189
115 206
120 189
125 196
130 199
135 177
140 186
145 183
150 206
155 206
160 212
165 212
170 216
175 216
180 219
185 219
190 223
195 212
200 212
205 212
210 209
215 212
220 219
225 212
230 206
235 206
240 206
245 209
250 209
255 209
260 209
265 212
270 212
275 209
280 209
285 212
290 209
295 209
300 209
305 209
310 209
315 209
320 209
325 209
330 209
335 212
340 212
345 209
350 212
355 212
360 212
365 212
370 212
375 216
380 216
385 216
390 216
395 216
400 216
405 219
410 219
415 219
420 223
425 223
430 223
435 223
440 223
445 219
450 223
455 223
460 223
465 223
470 223
475 223
480 223
485 219
490 223
495 230
500 219
505 223
510 227
515 227
520 227
525 230
530 234
535 234
540 234
545 238
550 234
555 234
560 206
565 209
570 209
575 171
580 168
585 151
590 146
595 141
600 146
605 138
610 141
615 143
620 149
625 143
630 177
635 162
640 171
645 168
650 171
655 171
660 168
665 171
670 171
675 165
680 186
685 183
690 186
695 189
700 192
705 196
710 199
715 206
720 212
725 216
730 219
735 223
740 223
745 223
750 216
755 212
760 212
765 212
770 209
775 206
780 199
785 209
790 209
795 216
800 216
805 219
810 223
815 223
820 227
825 230
830 234
835 242
840 246
845 246
850 253
855 253
860 257
865 257
870 262
875 262
880 262
885 266
890 270
895 270
900 266
905 270
910 270
915 270
920 270
925 274
930 274
935 274
940 278
945 278
950 278
955 283
960 283
965 283
970 283
975 283
980 283
985 283
990 283
995 283
1000 283
1005 283
1010 283
1015 283
1020 283
1025 283
1030 283
1035 283
1040 283
1045 283
1050 283
1055 283
1060 283
1065 283
1070 283
1075 283
1080 283
1085 283
1090 283
1095 283
1100 287
1105 287
1110 287
1115 287
1120 287
1125 287
1130 287
1135 287
1140 287
1145 287
1150 287
1155 287
1160 287
1165 287
1170 287
1175 287
1180 287
1185 287
1190 287
1195 287
1200 287
1205 287
1210 287
1215 287
1220 287
1225 287
1230 287
1235 287
1240 287
1245 287
1250 287
1255 287
1260 287
1265 292

I guess the r0 value isn't 10k -> try change to 20k What output if u run same code I did ?

200 ppm in condition air open. if ppm increase that is mean ch4 detection constration of gas. but a litte because the soil in condition dry. also ch4 dependent with temperature. temorrow i will change again to 20Kohm. we also validate using manual measurement. please wait until tomorrow.

Are u using a MQ-4 module or what? May i know do you solve ur problem?