Skip to content

A simple library to retrieve the information given from the MQ 2 sensor in arduino

Notifications You must be signed in to change notification settings

ViliusKraujutis/MQ-2-sensor-library

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

33 Commits
 
 
 
 
 
 
 
 

Repository files navigation

MQ-2 sensor library

This is a simple library to use with the MQ-2 sensor in arduino.

Based on this page: Sandbox electronics

The following page it's also useful if you want to know how to calibrate the sensor (it's for MQ-6 sensor but it works as the MQ-2 does): http://www.savvymicrocontrollersolutions.com/index.php?sensor=mq-6-gas-sensors

Usage

To intall the library to use it with the Arduino IDE, download it as zip and unzip it into your 'libraries' folder and restart the Arduino IDE.

To know how to use this library view the sample. Examples

Setup:

  #include <MQ2.h>
  
  int pin = A0;
  
  MQ2 mq2(pin);
  
  void setup(){
    mq2.begin();
  }

Read all data:

  float* values = mq2.read(true); //true to print the values in the Serial

Read specific data:

  float lpg = mq2.readLPG();
  
  float co = mq2.readCO();
  
  float smoke = mq2.readSmoke();

About

A simple library to retrieve the information given from the MQ 2 sensor in arduino

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • C++ 86.6%
  • Other 13.4%