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

IOT Lab Experiment No.3

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)
14 views3 pages

IOT Lab Experiment No.3

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: 3

Objective: Interfacing of the Gas Sensor with Arduino.

Hardware Required:

Figure: Grove - Gas Sensor (MQ2)


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.

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("Gas sensor warning up!");
delay(20000); // allow MQ-2 warning
}
void loop()
{
sensorValue =analogReAD(MQ2pin); // read analog pin 0

Serial.print("Sensor Value: ");


Serial.print(sensorValue);

If(sensorValue > 200)


{
Serial.print(“ | smoke detected!”)
}
Serial.printIn(“ “);
delay(1000); wait 2s for next reading

}
Observations:

Sensor Voltage

You might also like