Introduction
This experiment uses the MQ-4 gas sensor to detect gasoline fumes in the air.
Components Needed
- MQ-4 Gas Sensor
- Arduino
- Jumper Wires
Circuit Setup
- Connect the VCC pin of the MQ-4 sensor to 5V on the Arduino.
- Connect the sensor’s output to an analog input pin (e.g., A0) on the Arduino.
The sensor will output a signal proportional to the concentration of gasoline fumes detected.
Code for Gasoline Fume Detection
Upload the following code to your Arduino to detect gasoline fumes:
const int mq4Pin = A0;
void setup() {
Serial.begin(9600);
}
void loop() {
int gasValue = analogRead(mq4Pin);
Serial.print("Gasoline Fumes Level: ");
Serial.println(gasValue);
delay(1000);
}
Explanation
The MQ-4 sensor detects the concentration of gases such as methane and gasoline in the air and converts it into an analog voltage signal.
Troubleshooting
- If the sensor is not responding, check the sensor’s connections and power supply.
- Ensure the sensor is exposed to fumes or gases in a controlled environment.