Skip to content

Latest commit

 

History

History
43 lines (31 loc) · 1.21 KB

README.md

File metadata and controls

43 lines (31 loc) · 1.21 KB

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();