The MQ9 Gas Sensor is a member of the MQ Gas Sensors family. It operates as a Metal Oxide Semiconductor (MOS) gas sensor primarily designed to identify Carbon Monoxide, Methane, and Propane. It is capable of detecting concentrations of LPG, Propane, Hydrogen, Carbon Monoxide, and Methane gases. The sensor contains a sensitive element, primarily composed of aluminum-oxide-based ceramic coated with Tin dioxide (SnO2), enclosed within a stainless-steel mesh. When gases come into contact with this element, it causes a change in its electrical resistance. This alteration is then measured to determine the concentration of the gases. The sensor features a small heating element that preheats the sensor to bring it into the operational range.
Specifications:
- Operating Supply voltage: 5 volts
- Target Gas: LPG, Propane, CO, and Methane (CNG)
- Concentration Detection Range: 200 to 10000 ppm (parts per million) for methane (CH4)
- Heater consumption: less than 350mw
- Load resistance: 20KΩ
- Operating Temperature: Within a range of -10°C to 50°C
Components Required for this Arduino MQ9 Sensor Project:
- MQ-4 Methane Gas Sensor Module
- Small Piezoelectric Buzzer – 5V Active Buzzer
- Arduino Uno R3
- Jumper wires
Arduino MQ9 Gas Sensor Circuit Diagram
The MQ-9 sensor can be easily interfaced with Arduino, only requiring connections of four terminals of the sensor. The buzzer acts as a triggering alarm to confirm that the sensor detected gas.
To set up the MQ-4 sensor module, follow these steps:
- Link the VCC pin to the Arduino’s 5V connection.
- Attach the GND pin to the Arduino’s Ground (GND).
- Connect the A0 pin to one of the analog pins on the Arduino, like A0.
- Connect the D0 pin to a digital pin on the Arduino, for example, pin 12.
For the buzzer connection:
- Connect the positive (+ve) terminal of the buzzer to a digital pin on the Arduino, such as pin 8. Avoid connecting it to pin 13 to prevent the buzzer from beeping when the Arduino starts.
- Connect the other terminal of the buzzer to the ground (GND) of the Arduino.
Arduino MQ-9 Gas Sensor Code
Inside the code, we have set up all the pins initially. The code collects both analog and digital input data from the sensor. Additionally, it includes a buzzer that beeps when the threshold value changes upon detecting gas. The analog and digital values are then displayed on the serial monitor.
const int mqPin = A0; // Analog pin for MQ-4 sensor const int DO_Pin=12; const int buzzerPin = 8; // Digital pin for buzzer void setup() { pinMode(buzzerPin, OUTPUT); pinMode(DO_Pin, INPUT); // Configure D8 pin as a digital input pin Serial.begin(9600); } void loop() { int sensorValue = analogRead(mqPin); int threshold= digitalRead(DO_Pin); Serial.print(“threshold_value: “); Serial.print(threshold); //prints the threshold_value reached as either LOW or HIGH (above or underneath) Serial.print(“, “); Serial.print(“Sensor Value: “); Serial.println(sensorValue); delay(100); // Adjust the threshold value based on your sensor’s characteristics if (threshold==LOW) { digitalWrite(buzzerPin, HIGH); // Turn on the buzzer delay(200); // Buzzer on time digitalWrite(buzzerPin, LOW); // Turn off the buzzer } //delay(1000); // Wait before the next reading } |