Hooking up a gas & smoke (MQ-2) sensor

That last message from Erdin was what I needed. The resistor needs to be connected to both the GND and the Analog input. You can see the newly corrected Fritzing attached.

I knew it had worked as soon as I ran the original code on the new wiring. It started with values around 790-810 and slowly went down and down to the 500s and then the 400s and finally it settled around the upper 360s after 15 minutes. That's when I decided to test. I lit a match underneath the sensor and it went crazy. It shot to 800 immediately. I blew out the match and it stayed up in the 800 range and hovered there while the smoke billowed in my hand. When I moved my hand away and let the smoke dissipate it dropped to 600 and, a few seconds later, slowly worked its way back down to the upper 360s.

I modified the code slightly to map the values as a percentage: in other words I took the incoming range of 0 to 1023 and applied it to a range of 0 to 100. The "standard" mapped reading seems to be around 35-36 now and I can therefore check for differences from that to see if it's in the presence of smoke.

/*
  MQ-2 Sensor connected to Arduino Uno
  Both A pins and left H pin connected to 5V out
  Right H pin connected to GND
  Both B pins, and right H pin, connected to 22k ohms resistor and A0
*/

// Sensor value read from analog pin (range from 0 to 1023)
int iSensorValue = 0;

// Mapped value from 0 to 100
byte bySensorVal = 0;

// Message string to be displayed on serial monitor
char cMsg[124];

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

//////////////////////////////////////////////////////
//
// LOOP
//
void loop() {
  
  // Read input value on A0 and map it from 0 to 100
  iSensorValue = analogRead(A0);
  bySensorVal = map(iSensorValue, 0, 1023, 0, 100);
  
  // Display input value and mapped value
  sprintf(cMsg, "MQ-2 Sensor Value : %d (%d)", iSensorValue, bySensorVal);

  // Check for high value
  if (bySensorVal > 60) {
    Serial.print(cMsg);
    Serial.println(F(" *** DISTURBANCE IN THE FORCE! ***"));
  }
  else {
    Serial.println(cMsg);
  }
 
  // Loop 10 times per second
  delay(100);
}

Now I need to find some different gas samples to play around with to see how the sensor reacts ... but somehow without making myself sick at the same time.

Thank you ALL for your helpful and detailed replies. I am just at the beginnings of what I want this little device to do, and this is one of the simplest of the projects I have in my head, and I have already learned a TON here.

MQ-2 Breadboard.fzz (3.68 KB)