MQ-9 sensor project

Hi

I am trying to use the MQ-9 sensor with the arduino uno board for CO measurement. I connected the Vcc of the sensor board with 5V on the arduino board, the Ground with the ground and A0 of the sensor with A0 of the arduino. When I run my code I get -0,10 V as the R0 and an ovf for the sensor Volt. Could this be because I haven't done a "preheating" of the sensor?

My code is the following:

void setup() {
 
Serial.begin(9600);
}

void loop() {
 
float sensor_volt; 
 float RS_air; 
 float R0;  
 float sensorValue;

/*--- Get a average data by testing 100 times ---*/   
   for(int x = 0 ; x < 100 ; x++)
 {
   sensorValue = sensorValue + analogRead(A0);
 }
 sensorValue = sensorValue/100.0;
/*-----------------------------------------------*/

 sensor_volt = sensorValue/1024*5.0;
 RS_air = (5.0-sensor_volt)/sensor_volt; // omit *RL
 R0 = RS_air/9.9; // The ratio of RS/R0 is 9.9 in LPG gas
 
 Serial.print("sensor_volt = ");
 Serial.print(sensor_volt);
 Serial.println("V");
 
 Serial.print("R0 = ");
 Serial.println(R0);
 delay(1000);

}

Thanks

Ben

You don't initialize sensorValue!

Please use code tags when posting code, as described in the "How to use this forum" post.

Could this be because I haven't done a "preheating" of the sensor?

Since that is a required operation, it is really silly to not do it.

But in any case, you should not be powering the sensor from the Arduino 5V output, as those particular sensors are power hungry, and may draw too much current from that output.

jremington:
But in any case, you should not be powering the sensor from the Arduino 5V output, as those particular sensors are power hungry, and may draw too much current from that output.

Hi

How should I power the sensor if I should not use the 5V output?

Ben

How should I power the sensor if I should not use the 5V output?

What about using a 5V power supply?