Go Down

Topic: problem using two MQ-5 in one system (Read 1 time) previous topic - next topic


Hello everyone, I'm new arduino user.

I have an arduino project that uses two MQ-5 LPG sensor modules. I have tried the sensors individually, and they works properly. I used coding that convert analog value from the sensor to voltage value. The voltage will go higher as the concentration of the gas increments. If the LPG is given, and the voltage value more than 1,3 V it will makes the buzzer on.

The problem is when both of sensors are used together, one of them always getting error. The voltage value of the error sensor is always high, whereas there is not gas is given.
When I test that error sensor individually, it works normally. And when I used it together with another sensor, it becomes error again.
Is there anyone can give me solution?

Thanks before and sorry for my bad english ^^.


How is everything powered ?
How is it connected ?
Which Arduino board do you use ?
Do you use a breadboard ?
Please upload your sketch between code tags (use the button with the '#').

The MQ-5 gas sensor requires 5V for the heater.
If you use the 5V output of the Arduino board, it might not supply enough current for both.
I assume you have two load resistors and use two analog inputs ?
A breadboard have sometimes bad connections.


- everything get power from 5V output from arduino.
- I use arduino uno R3
- yes i use a breadboard.
here the sketch

Code: [Select]
int buzzer1 = 4;
int buzzer2 = 5;
int led1 = 11;
int led2 = 12;

void setup() {
  pinMode (buzzer1, OUTPUT);
  pinMode (buzzer2, OUTPUT);
  pinMode (led1, OUTPUT);
  pinMode (led2, OUTPUT);

void loop() {

  float vol1;
  int sensorValue1 = analogRead(A0);
  delay (1000);
   if (vol1>=1.3)
     digitalWrite(buzzer1, HIGH);
     delay (500);
     digitalWrite(buzzer1, LOW);
     delay (10);
     digitalWrite(led1, HIGH);
     digitalWrite(buzzer1, LOW);
     digitalWrite(led1, LOW);
  float vol2;
  int sensorValue2 = analogRead(A1);
  delay (1000);
   if (vol2>=1.3)
     digitalWrite(buzzer2, HIGH);
     delay (500);
     digitalWrite(buzzer2, LOW);
     delay (10);
     digitalWrite(led2, HIGH);
     digitalWrite(buzzer2, LOW);
     digitalWrite(led2, LOW);

yes you are right i use two analog input.
this sensor needs to preheat over 24 hours. does it mean i have to make this sensor on for over 24 hours?
thanks for your help :D


Could you change 'A0' into '0' and 'A1' into '1' for the analogRead() function.
The analogRead() function takes an integer (0...5) as parameter.
Could you change '1024' into '1024.0' (twice), to be sure the calculation is done with floating point.

Please measure the 5V pin of the Arduino. Is it 5.0V ? I hope not less than 4.5V. I don't know if that pin can supply enough current for two of those sensors.
Do you use USB to power everything ?
Perhaps you could use a wall wart adapter, but you have to check that the voltage regulator on the Arduino board doesn't get too hot.

A pre-heat of 24 hours: let it stay on for 24 hours.
But you must be sure that it is connected properly and that the heater voltage is 5V, otherwise the pre-heat won't be valid.

If this all doesn't help, could you upload a photo of how you have it connected ?


Yes I use USB to power everything. I will try your suggestion, I hope it works.
This is my block diagram.


If you have your wiring like the drawing, it is not correct.
The GND seems to be connected to the bottom row of the breadboard, but you use that row for +5V.
The sensors are powered by Vin, but that is a input for a power supply.

Vin is almost the same as the DC plug for a wall wart adapter. You can apply 7-12V on Vin to power the Arduino board.

Do you have a multimeter, to check all voltages ?


sorry, I was wrong when drawing connections 5V and GRND. In practice, I've been using 5V and GRND correctly as you said (see block diagram). and the result is such a problem that I've said before.
okay, I will check the voltage first.
thank you :)


I've checked the value of the Arduino 5V output voltage with a multimeter that is only 4 volts and the current value that is through the sensor is equal to 100 mA. do i have to use other sources for sensors? what if I use a 5V power supply circuit?

I have other problem, if both sensors detect gases simultaneously, then the sound of the buzzer did not go on simultaneously, but alternately. whether it occurs because the current value?

I'am still don't understand with your suggestion to change 'A0' into '0' and 'A1' into '1' for the analogRead() function. You mean the Arduino pin used is pin 0 and pin 1, or just coding that changed and still use analog pin?

sorry if I ask too many questions, but I really need the answer to complete my project. thank you  :)


If you have a power supply of 5V, you can use that to power the (heater of the) sensors.

About the 'A0' and '0', I ment the coding.
Code: [Select]

int sensorValue1 = analogRead(0);
int sensorValue2 = analogRead(1);

I can't say something about the problem with detection of gases simultaniously. At this moment it is not reliable (running at 4V), so anything can happen.

Go Up

Please enter a valid email to subscribe

Confirm your email address

We need to confirm your email address.
To complete the subscription, please click the link in the email we just sent you.

Thank you for subscribing!

via Egeo 16
Torino, 10131