--> Project II - 5 Accessing The MQ-2 Gas Sensor (Arduino Based) | basic arduino tutorial

Monday, August 7, 2017

Project II - 5 Accessing The MQ-2 Gas Sensor (Arduino Based)

| Monday, August 7, 2017
Accessing The MQ-2 Gas Sensor



This tool will detect smoke with MQ-2 sensor with otput sensor is analog data so it must be converted to digital data using ADC inside Arduino. If the sensor detects the presence of smoke or gas, the value of the ADC will increase according to the amount of smoke or gas detected. The value data will then be displayed on an LCD. It also connects an LED on the arduino on the pin 13th. so when the ADC value is reached at a certain point the LED will light up.

Hardware Requirement
  • MQ - 2 Gas Sensor Module
  • Arduino UNO
  • LCD 2x16 Module
  • Power supply +5 Volt
MQ-2 Gas Sensor Module | Source


Schematic



Arduino - LCD Wiring



Arduino - MQ-2 Sensor



Source Code/Sketch
#include<LiquidCrystal.h>
LiquidCrystal lcd (2,3,4,5,6,7);
int redLed = 13;
int smokeA0 = A0;
//nilai thresshold
int sensorThres = 600;

void setup() {
//inisialisasi I/O
pinMode(redLed, OUTPUT);
pinMode(smokeA0, INPUT);
Serial.begin(9600);
lcd.begin(16,2);
}

void loop() {
int analogSensor = analogRead(smokeA0);
lcd.clear();
lcd.setCursor(1,0);
lcd.print("ADC : ");
lcd.setCursor(7,0);
lcd.print(analogSensor);
delay(100);

//membandingkan nilai pembacaan sensor dengan thresshold
if (analogSensor > sensorThres){
//lampu akan menyala jika nilai sensor yang terbaca melebihi
// dari nilai thresshold
digitalWrite(redLed, HIGH); }
else{
digitalWrite(redLed, LOW); }
delay(100);
}


How it Works

In the LCD will display the value of ADC readings of MQ2 sensor, when the ADC value reaches 600 then the LEDs connected on Arduino on Pin 13th will light up.


Video Project II - 5 Accessing The MQ-2 Gas Sensor (Arduino Based)





Download the required file.

Related Posts

No comments:

Post a Comment