
- #ARDUINO SENSORS TUTORIAL MQ2 TUTORIAL HOW TO#
- #ARDUINO SENSORS TUTORIAL MQ2 TUTORIAL SERIAL#
- #ARDUINO SENSORS TUTORIAL MQ2 TUTORIAL CODE#
- #ARDUINO SENSORS TUTORIAL MQ2 TUTORIAL SERIES#
SensorValue = analogRead(MQ2pin) // read analog input pin A0 Serial.println('Gas sensor warming up!') ĭelay(20000) // allow the MQ2 sensor to warm up for 20 sec
#ARDUINO SENSORS TUTORIAL MQ2 TUTORIAL SERIAL#
Serial.begin(9600) // sets the serial port to 9600 Int greenLed = 11 // connected to D11 pin of Arduinoįloat sensorValue //variable to store sensor value Int redLed = 12 // connected to D12 pin of Arduino #define MQ2pin (0) // connected to A0 pin of Arduino
#ARDUINO SENSORS TUTORIAL MQ2 TUTORIAL CODE#
Copy the below code in Arduino IDE and compile then upload. It is configured with 2 LED’s which acts as visual indicators. This code is simple and easy to understand. We have connected Analog pin of gas sensor to A0 pin of Arduino and power supply Vcc and GND respectively. MQ2 sensor is connected with Arduino Uno. Detects or measure gases like Alcohol, LPG, Propane, Hydrogen, Carbon Mono Oxide and methane.The output value will be directly proportional to the concentration of the gas. You can try different things with this qualities and check how the sensor responds to various convergence of gas and build up your program appropriately.

Here you have to read the analog values (0-5V) with a microcontroller. In similar way you can use the analog pin to get the values. After pre- heating the sensor will work properly to detect gasses or detect the PPM level. You have to power on the module and it might take 15 min to complete pre-heating. If the sensor senses a gas the output led will be turned on.Īlso do remember that theses sensor modules have pre-heating time. If there is no gas detected then output LED will be in off state. Since there are two pins present in the module, hence you can use either the digital pin or the analog pin to get results.Īll you have to do is power up the module using 5V which will enable the power led (Red in color). PIR based Motion Switch | PIR Sensor Lightĭetecting gas using MQ2 sensor is very easy and simple.Interfacing LM35 Temp Sensor with Arduino.
#ARDUINO SENSORS TUTORIAL MQ2 TUTORIAL HOW TO#

If you want to detect gas only then you can use the module. These sensors can either be bought as a module or as the sensor alone.
#ARDUINO SENSORS TUTORIAL MQ2 TUTORIAL SERIES#
MQ series gas sensors are most widely used for detecting different types of gas. If there is any presence of gas detected it will send a notification to Arduino and Arduino to take actions accordingly.

In this tutorial the MQ2 gas sensor keeps on monitoring the gas. Parts Listįor building this project you need some basic components. Lets quickly see what are the components needed to build this project. You can also modify it according to your need. By adding few more components like buzzer and led will enhance the circuit. This tutorial can work as a gas alarm system. This tutorial is for absolute beginners, where they can understand the concept of connecting a gas sensor with Arduino Uno. In this article we are going to learn about interfacing MQ2 Gas Sensor with Arduino. There are many gas sensors available in the market which detects different types of gases. Conclusion Interfacing MQ2 Gas Sensor with Arduino
