• Stars
    star
    166
  • Rank 227,748 (Top 5 %)
  • Language
    C++
  • License
    MIT License
  • Created almost 6 years ago
  • Updated about 1 year ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

We present a unified library for MQ sensors, this library allows to read MQ signals easily from Arduino, Genuino, ESP8266, ESP-32 boards whose references are MQ2, MQ3, MQ4, MQ5, MQ6, MQ7, MQ8, MQ9, MQ131, MQ135, MQ136, MQ303A, MQ309A.

DOI Build Status Contributors Forks Stargazers Issues MIT License LinkedIn

MQSensorsLib

We present a unified library for MQ sensors, this library allows to read MQ signals easily from Arduino, Genuino, ESP8266, ESP-32 boards whose references are MQ2, MQ3, MQ4, MQ5, MQ6, MQ7, MQ8, MQ9, MQ131, MQ135, MQ303A, MQ309A.

Table of Contents

Getting Started

//Include the library
#include <MQUnifiedsensor.h>
/************************Hardware Related Macros************************************/
#define         Board                   ("Arduino UNO")
#define         Pin                     (A4)  //Analog input 4 of your arduino
/***********************Software Related Macros************************************/
#define         Type                    ("MQ-4") //MQ4
#define         Voltage_Resolution      (5)
#define         ADC_Bit_Resolution      (10) // For arduino UNO/MEGA/NANO
#define         RatioMQ4CleanAir        (4.4) //RS / R0 = 60 ppm 
/*****************************Globals***********************************************/
//Declare Sensor
MQUnifiedsensor MQ4(Board, Voltage_Resolution, ADC_Bit_Resolution, Pin, Type);
// Setup
MQ4.setRegressionMethod("Exponential"); //_PPM =  a*ratio^b
MQ4.setA(1012.7); MQ4.setB(-2.786); // Configure the equation to to calculate CH4 concentration
MQ4.setR0(3.86018237); // Value getted on calibration
// Loop
MQ4.init();
MQ4.update();
float ppmCH4 = MQ4.readSensor();

Wiring

Sensor

Important points:

Points you should identify
  • VCC -> 5V Power supply (+) wire
  • GND -> GND Ground (-) wire
  • AO -> Analog Output of the sensor
Data of board that you should have
  • RL Value in KOhms
Graph

Wiring_MQSensor

RS/R0 value (From datasheet of your sensor)

  • RS/R0 (Clean air - English) -> (Aire puro - Spanish)
  • Note: RS/R0 is equal to Ratio variable on the program Graph from datasheet

Arduino

Arduino_Wiring_MQSensor

MQ-7 / MQ-309A

** Note ** issue: MQ-7 and MQ-309 needs two different voltages for heater, they can be supplied by PWM and DC Signal controlled by your controller, another option is to use two different power sources, you should use the best option for you, next i will show the PWM option and on the examples this will be the way . MQ-7_MQ-309

ESP8266-ESP32

ESP8266_Wiring_MQSensor

ESP32 WROOM 32D

The ESP32 WROOM 32D does not need an external power supply. A0 goes to PIN36, Vcc to 3v3 and GND to any GND port on the board. Check the ESP2/ESP32_WROOM_32 folder to fixing the measuring issue when connecting to wifi.

Manuals

User Manual (v1.0) 12.2019

Manual

User Manual (v2.0) 04.2020

Manual

Serial debug (optional)

If your sensor is an MQ2 (Same for others sensors):

  • To enable on setup wrote
MQ2.serialDebug(true); 
  • And on Loop Wrote
MQ2.serialDebug(); 
  • Result:

Serial debug output

Note:

  • #c5f015 Yellow -> Calibration status.
  • #008000 Green -> Hardware and software characteristics.
  • #f03c15 Red -> Headers of the library calculations.
  • Only valid for 1 gas sensor readings.

Usage

  • Quick troubleshooting, since it shows everything the library does and the results of the calculations in each function.

Prerequisites

You'll need Arduino desktop app 1.8.9 or later.

Sensor manufacturers:

Sensor Manufacture URL Datasheet
MQ-2 HANWEI Electronics datasheet
MQ-3 HANWEI Electronics datasheet
MQ-4 HANWEI Electronics datasheet
MQ-5 HANWEI Electronics datasheet
MQ-6 HANWEI Electronics datasheet
MQ-7 HANWEI Electronics datasheet
MQ-8 HANWEI Electronics datasheet
MQ-9 HANWEI Electronics datasheet
MQ-131 HANWEI Electronics datasheet
MQ-135 HANWEI Electronics datasheet
MQ-136 HANWEI Electronics datasheet
MQ-303A HANWEI Electronics datasheet
MQ-309A HANWEI Electronics datasheet

Info of datasheets

Review WPDigitalizer folder website

Installing

Clone this repository into your desktop machine

git clone https://github.com/miguel5612/MQSensorsLib

Running the tests

Use calibration systems if you have several sensors that read the same gas.

Break down into end to end tests

These tests can re-adjust values defined previously and you can contribute to improve conditions or features obtained from particular scenes.

Examples/MQ-3

And coding style tests

These tests may generate statistics validation using descriptive tools for quantitative variables.

Examples/MQ-board.ino

Built With

  • Data sheets - Curves and behavior for each sensor, using logarithmic graphs.
  • Main purpose - Every sensor has high sensibility for a specific gas or material.

Contributing

Please read CONTRIBUTING.md for details on our code of conduct, and the process for submitting pull requests to us.

Reviewers

  • PhD. Jacipt A Ramón V. - GitHub - CV

Authors

Collaborators

See also the list of contributors who participated in this project.

License

This project is licensed under the MIT License - see the LICENSE.md file for details

Cite as

  • Plain text: Califa Urquiza, Miguel Angel, Contreras Contreras, Ghiordy, & Carrillo Amado, Yerson Ramiro. (2019, September 3). miguel5612/MQSensorsLib: Arduino Preview V1.03 (Version 1.0.3). Zenodo. http://doi.org/10.5281/zenodo.3384301
  • CSL: { "publisher": "Zenodo", "DOI": "10.5281/zenodo.3384301", "title": "miguel5612/MQSensorsLib: Arduino Preview V1.03", "issued": { "date-parts": [ [ 2019, 9, 3 ] ] }, "abstract": "

    Publishing on Zenodo platform as software in order to extend its applications for other works allowing to recognize MQSensorLib's Authors this work into scientific community using Digital Object Identifier System (DOI).

    ", "author": [ { "family": "Califa Urquiza, Miguel Angel" }, { "family": "Contreras Contreras, Ghiordy" }, { "family": "Carrillo Amado, Yerson Ramiro" } ], "version": "1.0.3", "type": "article", "id": "3384301" }
  • BibTeX: @misc{califa_urquiza_miguel_angel_2019_3384301, author = {Califa Urquiza, Miguel Angel and Contreras Contreras, Ghiordy and Carrillo Amado, Yerson Ramiro}, title = {miguel5612/MQSensorsLib: Arduino Preview V1.03}, month = sep, year = 2019, doi = {10.5281/zenodo.3384301}, url = {https://doi.org/10.5281/zenodo.3384301} }

Sponsor

More Repositories

1

ThermistorLibrary

Marlyn based thermistor library for read temperature.
C
50
star
2

MQSensorsLib_Docs

Documentation about sensors MQ
Jupyter Notebook
15
star
3

sistema-de-supervision-y-apagado-remoto-para-equipos-de-impresion-3D.

Diseño e implementación de un sistema de supervision y apagado remoto para impresoras 3D
C++
4
star
4

AirQWeb

Dronefenix AirQ APP
JavaScript
2
star
5

Peltier_Fridge

This mini refrigerator performs temperature measurement using an LM35, comparing it with an arduino and controlling it through a relay activated at 5V (Module d1 relay) cooling the beverages using a peltier cell.
C++
2
star
6

PIC_Excercises

Clock work for Microcontroller classroom 2020
SWIG
2
star
7

ArduinoLCDTFT_CNC_Shield

Two arduinos uno joined using serial port, one with GRBL and one with LCD TFT
C++
2
star
8

On-SerialMonitor

Monitor serial para guardar datos provenientes de arduino
Python
2
star
9

TempHumDatalogger

This repository contains temperature logs measured in calibration laboratory of cens
Jupyter Notebook
2
star
10

Square-root-emu8086

This code explains how to calculate square root in assembly languaje
Assembly
2
star
11

PowerMonitor

Power Monitor using two PZEM004T, Wemos and MQTT server
C++
2
star
12

Salvarting_Ventilator

Arduino low cost respirator to assist coronavirus crisis.
C++
2
star
13

Autoclave-V1.0

Sistema para el control de tiempo y temperatura de una autoclave para el departamento de biologia en la universidad Francisco de Paula Santander. Esta implementado con un arduino uno y permite con A seleccionar el tiempo y con B la temperatura. El tiempo comienza a contar desde el momento en que se alcanza la temperatura seleccionada
Arduino
2
star
14

Cubo-led-3x3

Este codigo te permite hacer encender un cubo led 3x3
C++
1
star
15

On_TempHum_logger

C++
1
star
16

ML_ACUEDUCTO_TURBIDEZ

ML Automatic learning algorithm for control RPM of floculator
Jupyter Notebook
1
star
17

ML_Coursera

Machine learning examples on octave or matlab
MATLAB
1
star
18

Arduino_Utils

Codigos utiles para tus proyectos hechos con arduino
C
1
star
19

CNC_Yersson_Laser

C++
1
star
20

DL-card-programmer

C#
1
star
21

Medidor-de-temperatura-ambiente-

En este proyecto aprenderás como medir la temperatura y la humedad de tu hogar empleando la api de Thingspeak, micropython en el NODE MCU.
Python
1
star
22

adBlockByHostsFile

Cmd automatic host file update
Batchfile
1
star
23

PLC_Arduino_RS485

Conexion entre arduino y plc (DVP-14SS2)
C++
1
star
24

VPS_Settings_Full

Configuracion para publicar en un vps una aplicacion que usa wordpress, mysql, phpmyadmin, nvm y certbot
1
star
25

Arduino_Metal_Detector

Detector de metales usando arduino
C++
1
star
26

DL-Board-Programmer-using-Arduino

DL_Board_Programmer_Using_Arduino
C#
1
star
27

Control-de-cuatro-relevos-Node-Mcu-Wifi-ESP-07

Se controlan luces de una ferreteria mediante una interfaz web (html/css) implementada en el Node Mcu o Esp-07
Arduino
1
star
28

JACUZZI_PLC_2HIDROMASAJE_2CIRCULACION

Programacion PLC, Edificio SAN FELIPE, ZONA: Social. Controla: 2 motobombas de hidromasaje, 2 motobombas de circulacion, 1 motobomba de mantenimiento (Las 4 motobobas funcionan alternadas).
1
star
29

solucionadorMapaK

Solucionador de mapas de Karnaugh usando MATLAB
MATLAB
1
star