0% found this document useful (0 votes)
4 views

Arduino Uno Based Gas Sensor

Uploaded by

rupu ghosh
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
4 views

Arduino Uno Based Gas Sensor

Uploaded by

rupu ghosh
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 5

Experiment No: 05.

Experiment Name: Study and Observation of Arduino Uno Based Gas Sensor.
Objective:
To study the functionality of a gas sensor using an Arduino Uno and to detect the presence of smoke/gas
using the sensor's digital output (D0). Additionally, determine if gas concentration is within acceptable
limits by finding a threshold value.
Theory:

Gas sensors, such as the MQ series, are widely used to detect the presence of various gases,
including smoke, carbon monoxide, and methane. These sensors consist of a sensitive layer that
changes resistance when exposed to gases, producing an output that indicates gas presence. The
MQ gas sensor provides both analog (A0) and digital (D0) outputs, where D0 is activated when the
gas concentration crosses a preset threshold.

In this experiment, we focus on the digital output (D0), which goes HIGH when gas concentration
exceeds a certain level. By observing the threshold, we can determine whether the environment is
safe or needs attention due to high gas levels.

Required Hardware with Quantity:

Arduino Uno - 1
Gas Sensor Module (e.g., MQ-2, MQ-135) - 1
Jumper Wires - 5
Breadboard – 1

Required Software:

1. Arduino IDE (for writing and uploading code).

Working Procedure:

• Hardware Setup: Connect the MQ sensor to the Arduino Uno as follows:

• Connect the sensor's VCC pin to the Arduino’s 5V.


• Connect the GND pin of the sensor to the GND on the Arduino.
• Connect the D0 pin of the sensor to a digital input pin on the Arduino (e.g., pin 2).

• Threshold Adjustment: The MQ sensor typically has a potentiometer that allows manual
adjustment of the threshold level. Set the threshold by turning the potentiometer until the sensor
responds at the desired gas concentration level.

• Programming the Arduino: Write and upload a sketch to the Arduino that reads the digital
signal (D0) from the sensor. When D0 sends a HIGH signal (indicating gas presence above the
threshold), the Arduino should respond by triggering an alert or indicator (e.g., turning on an LED).
• Testing: Expose the sensor to different concentrations of gas or smoke and observe the behavior.
Adjust the threshold potentiometer if necessary to get accurate detection at the desired
concentration level.

Hardware Arrangement Diagram:

A simple diagram showing Arduino, gas sensor, connections for D0 can be inserted here. The
sensor D0 connects to digital pin 2 on Arduino, and VCC/GND to 5V/GND.

Figure 01: Hardware Arrangement

Sketch:

Finding the threshold value

#define MQ135pin 0
float sensorValue; // variable to store sensor value
void setup() {
Serial.begin(9600); // sets the serial port to 9600
Serial.println("MQ135 warming up!");
delay(20000); // allow the MQ135 to warm up
}
void loop() {
sensorValue = analogRead(MQ135pin); // read analog input pin 0
Serial.print("Sensor Value: ");
Serial.println(sensorValue);
delay(2000); // wait 2s for next reading
}
When you run the sketch, you should see readings similar to the ones below:
• In the absence of smoke/gas (around 100)
• In the presence of smoke/gas (around 400)

Determines whether the gas concentration is within acceptable limits


#define Threshold 400
#define MQ135pin 0
float sensorValue; //variable to store sensor value
void setup() {
Serial.begin(9600); // sets the serial port to 9600
Serial.println("MQ135 warming up!");
delay(20000); // allow the MQ135 to warm up
}
void loop() {
sensorValue = analogRead(MQ135pin); // read analog input pin 0
Serial.print("Sensor Value: ");
Serial.print(sensorValue);
if(sensorValue > Threshold)
{
Serial.print(" | Smoke detected!");
}
Serial.println("");
delay(2000); // wait 2s for next reading
}

Detecting the Presence of Smoke/Gas using Digital Output (D0)

#define MQ135pin 8
int sensorValue; //variable to store sensor value
void setup() {
Serial.begin(9600); // sets the serial port to 9600
Serial.println("MQ135 warming up!");
delay(20000); // allow the MQ135 to warm up
}
void loop() {
sensorValue = digitalRead(MQ135pin); // read digital output pin
Serial.print("Digital Output: ");
Serial.print(sensorValue);
// Determine the status
if (sensorValue) {
Serial.println(" | Smoke: -");
} else {
Serial.println(" | Smoke: Detected!");
}
delay(2000); // wait 2s for next reading
}
Result and Output:

We will find threshold value by running the “Finding the threshold value” code and the value is
400.
Fig02: Finding threshold value

By running “Determines whether the gas concentration is within acceptable limits” we find that
our surrounding environment is within acceptable limit or not.

Fig03: Serial Monitor Screen


By running “Detecting the Presence of Smoke/Gas using Digital Output (D0)” we can see value
through digital output means 0 or 1.

Fig04: Serial Monitor Screen

Conclusion:

In this experiment, an Arduino Uno-based gas sensor was used to monitor gas concentration levels. By
adjusting the threshold value, we could reliably detect gas concentrations above acceptable limits. This
setup is effective for applications that require gas detection and warning mechanisms, such as in
industrial safety systems or home safety devices. The digital output (D0) of the MQ sensor provides a
straightforward method for monitoring gas concentrations.

You might also like