0% found this document useful (0 votes)
17 views3 pages

IOT Lab Experiment No. 4

Uploaded by

rei0zlitch
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
17 views3 pages

IOT Lab Experiment No. 4

Uploaded by

rei0zlitch
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 3

Experiment 4

Objective: Interfacing of the Gas Sensor with Arduino.


Introduction:

The Grove - Gas Sensor (MQ2) module is useful for gas leakage detection (home
and industry). It is suitable for detecting H2, LPG, CH4, CO, Alcohol, Smoke or
Propane. Due to its high sensitivity and fast response time, measurement can be taken
as soon as possible. The sensitivity of the sensor can be adjusted by potentiometer.

Hardware Required:
Component Name Quantity

Arduino UNO 1

Gas Sensor 1

USB Cable 1

Breadboard 1

Jumper wires several


Connection Diagram:

Steps of working:

1. Connect Grove-Gas_Sensor-MQ2 to port A0 of Grove-Base Shield.


2. Plug Grove - Base Shield into Arduino.
3. Connect Arduino to PC via a USB cable.
4. Upload the code.
5. Observe the clicking sound of the relay that states the ON and OFF
constantly.

Sketch:

This sketch works by setting 5V supply pin of Arduino as for the control of
relay module. After that the run a loop that continually sends that value as
voltage to the D6 with the delay given.
#define MQ2pin (0)

float sensorValue; // variable to store sensor value

void setup( )

{
Serial.begin(9600); // set the serial port to 9600

Serial.println("MQ2 warning up!");

delay(20000); // allow MQ-2 warm up


}
void loop( )
{
sensorValue =analogReAD(MQ2pin); // read analog pin 0

Serial.print("Sensor Value: ");


Serial.println(sensorValue);

if(sensorValue > 200)


{
Serial.print(“ | Gas detected!”)

Serial.println(“ “);
delay(20000); // wait 20 sec for next reading
}

Observations:
Sensor Voltage 205 mV

Sensor Voltage 235 mV

Sensor Voltage 250 mV

You might also like