Skip to content

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

License

Notifications You must be signed in to change notification settings

labay11/MQ-2-sensor-library

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

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

License

Copyright 2015 labay11

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

About

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

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages