MQSensorsLib/README.md

207 lines
8.5 KiB
Markdown
Raw Normal View History

2019-09-02 20:00:44 -05:00
[![DOI](https://zenodo.org/badge/170540207.svg)](https://zenodo.org/badge/latestdoi/170540207)
2019-09-02 19:40:29 -05:00
![Build Status](https://travis-ci.org/dwyl/esta.svg?branch=master)
2019-09-02 19:40:02 -05:00
2019-02-13 11:26:33 -05:00
# MQSensorsLib
2019-04-17 10:51:56 -05:00
2019-08-15 10:03:05 -05:00
This is a unified library to use sensors MQ: 2, 3, 4, 5, 6, 7, 8, 9, 131, 135, 303A and 309A.
2019-04-17 10:51:56 -05:00
## Getting Started
```
2020-04-02 09:35:18 -05:00
//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
2020-03-26 13:23:05 -05:00
MQ4.setRegressionMethod("Exponential"); //_PPM = a*ratio^b
MQ4.setA(1012.7); MQ4.setB(-2.786); // Configurate the ecuation values to get CH4 concentration
2020-04-02 09:35:18 -05:00
MQ4.setR0(3.86018237); // Value getted on calibration
// Loop
2020-03-26 13:23:05 -05:00
MQ4.init();
MQ4.update();
2019-08-15 09:18:13 -05:00
float ppmCH4 = MQ4.readSensor();
2019-04-17 10:51:56 -05:00
```
2020-03-29 21:45:42 -05:00
## Wiring
2020-04-02 09:35:18 -05:00
### 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](https://raw.githubusercontent.com/miguel5612/MQSensorsLib_Docs/master/static/img/Points_explanation.jpeg)
2020-04-02 09:51:43 -05:00
#### RS/R0 value (From datasheet of your sensor)
2020-04-02 09:56:03 -05:00
* RS/R0 (Clean air - English) -> (Aire puro - Spanish)
2020-04-02 09:51:43 -05:00
* **Note**: RS/R0 is equal to Ratio variable on the program
![Graph from datasheet](https://raw.githubusercontent.com/miguel5612/MQSensorsLib_Docs/master/static/img/Graph_Explanation.jpeg)
2020-03-29 21:45:42 -05:00
### Arduino
![Arduino_Wiring_MQSensor](https://raw.githubusercontent.com/miguel5612/MQSensorsLib_Docs/master/static/img/MQ_Arduino.PNG)
### ESP8266
![ESP8266_Wiring_MQSensor](https://raw.githubusercontent.com/miguel5612/MQSensorsLib_Docs/master/static/img/MQ_ESP8266.PNG)
2020-04-02 09:35:18 -05:00
### User Manual (v1.0) 12.2019
2019-12-09 07:21:52 -05:00
[Manual](https://drive.google.com/open?id=1BAFInlvqKR7h81zETtjz4_RC2EssvFWX)
2020-04-02 09:35:18 -05:00
### User Manual (v2.0) 04.2020
[Manual](https://github.com/miguel5612/MQSensorsLib_Docs/blob/master/Docs/MQSensorLib_2.0.pdf)
2019-12-09 07:21:52 -05:00
2020-04-02 09:51:43 -05:00
### 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](https://github.com/miguel5612/MQSensorsLib_Docs/blob/master/static/img/Serial_Mon_Explanation.jpeg?raw=true)
**Note**:
* ![#c5f015](https://placehold.it/15/c5f015/000000?text=+) `Yellow -> Calibration status.`
* ![#008000](https://placehold.it/15/008000/000000?text=+) `Green -> Hardware and software characteristics.`
* ![#f03c15](https://placehold.it/15/f03c15/000000?text=+) `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.
2019-04-17 10:51:56 -05:00
### Prerequisites
2019-08-27 16:25:56 -05:00
You'll need Arduino desktop app 1.8.9 or later.
2019-04-17 10:51:56 -05:00
2019-08-27 16:25:56 -05:00
### Sensor manufacture:
| Sensor | Manufacture | URL Datasheet |
2019-05-18 14:02:32 -05:00
|----------|----------|----------|
| MQ-2 | Pololulu| [datasheet](https://www.pololu.com/file/0J309/MQ2.pdf) |
2019-05-18 13:59:18 -05:00
| MQ-3 | Sparkfun | [datasheet](https://www.sparkfun.com/datasheets/Sensors/MQ-3.pdf) |
| MQ-4 | Sparkfun | [datasheet](https://www.sparkfun.com/datasheets/Sensors/Biometric/MQ-4.pdf) |
| MQ-5 | parallax | [datasheet](https://www.parallax.com/sites/default/files/downloads/605-00009-MQ-5-Datasheet.pdf) |
| MQ-6 | Sparkfun | [datasheet](https://www.sparkfun.com/datasheets/Sensors/Biometric/MQ-6.pdf) |
| MQ-7 | Sparkfun | [datasheet](https://www.sparkfun.com/datasheets/Sensors/Biometric/MQ-7.pdf) |
| MQ-8 | Sparkfun | [datasheet](https://dlnmh9ip6v2uc.cloudfront.net/datasheets/Sensors/Biometric/MQ-8.pdf) |
2019-05-18 14:03:00 -05:00
| MQ-9 | Haoyuelectronics | [datasheet](http://www.haoyuelectronics.com/Attachment/MQ-9/MQ9.pdf) |
| MQ-131 | Sensorsportal | [datasheet](http://www.sensorsportal.com/DOWNLOADS/MQ131.pdf) |
2019-05-18 13:59:18 -05:00
| MQ-135 | HANWEI Electronics | [datasheet](https://www.electronicoscaldas.com/datasheet/MQ-135_Hanwei.pdf) |
| MQ-303A | HANWEI Electronics | [datasheet](http://www.kosmodrom.com.ua/pdf/MQ303A.pdf) |
| MQ-309A | HANWEI Electronics | [datasheet](http://www.sensorica.ru/pdf/MQ-309A.pdf) |
2019-08-15 09:15:21 -05:00
### Info of datasheets
2020-03-27 08:22:44 -05:00
Review WPDigitalizer [folder](https://github.com/miguel5612/MQSensorsLib_Docs/tree/master/WPDigitalizer) [website](https://automeris.io/WebPlotDigitizer/)
2019-05-19 09:49:06 -05:00
2019-04-17 10:51:56 -05:00
### Installing
2019-08-27 16:25:56 -05:00
Clone this repository into your desktop machine
2019-04-17 10:51:56 -05:00
```
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
2019-08-27 16:25:56 -05:00
These tests can re-adjust values defined previously and you can contribute to improve conditions or features obtained from particular scenes.
2019-04-17 10:51:56 -05:00
```
2019-08-15 12:03:34 -05:00
Examples/MQ-3
2019-04-17 10:51:56 -05:00
```
### And coding style tests
2019-08-27 16:25:56 -05:00
These tests may generate statistics validation using descriptive tools for quantitative variables.
2019-04-17 10:51:56 -05:00
```
2019-08-15 12:03:34 -05:00
Examples/MQ-board.ino
2019-04-17 10:51:56 -05:00
```
## Built With
2020-03-27 08:22:44 -05:00
* [Data sheets](https://github.com/miguel5612/MQSensorsLib_Docs/tree/master/Datasheets) - Curves and behavior for each sensor, using logarithmic graphs.
* [Main purpose](https://github.com/miguel5612/MQSensorsLib_Docs/blob/master/static/img/bg.jpg) - Every sensor has high sensibility for a specific gas or material.
2019-04-17 10:51:56 -05:00
## Contributing
2020-03-27 08:22:44 -05:00
Please read [CONTRIBUTING.md](https://github.com/miguel5612/MQSensorsLib/blob/master/CONTRIBUTING.md) for details on our code of conduct, and the process for submitting pull requests to us.
2019-04-17 10:51:56 -05:00
## Authors
2019-05-10 09:32:04 -05:00
* **Miguel A. Califa U.** - [*GitHub*](https://github.com/miguel5612) - [CV](https://scienti.colciencias.gov.co/cvlac/visualizador/generarCurriculoCv.do?cod_rh=0000050477)
* **Ghiordy F. Contreras C.** - [*GitHub*](https://github.com/Ghiordy) - [CV](https://scienti.colciencias.gov.co/cvlac/visualizador/generarCurriculoCv.do?cod_rh=0000050476)
* **Yersson R. Carrillo A.** - [*GitHub*](https://github.com/Yercar18/Dronefenix) - [CV](https://scienti.colciencias.gov.co/cvlac/visualizador/generarCurriculoCv.do?cod_rh=0001637655)
2019-05-20 10:42:40 -05:00
2019-08-27 16:25:56 -05:00
## Collaborators
2019-08-15 09:15:21 -05:00
2020-04-02 11:01:56 -05:00
* **Andres A. Martinez.** - [*Github*](https://github.com/macsi) - [CV](https://www.linkedin.com/in/andr%C3%A9s-acevedo-mart%C3%ADnez-73ab35185/?originalSubdomain=co)
* **Juan A. Rodríguez.** - [*Github*](https://github.com/Obiot24) - [CV]()
2019-08-15 10:04:14 -05:00
* **Mario A. Rodríguez O.** - [*GitHub*](https://github.com/MarioAndresR) - [CV](https://scienti.colciencias.gov.co/cvlac/visualizador/generarCurriculoCv.do?cod_rh=0000111304)
2019-05-20 10:42:40 -05:00
2019-04-18 00:50:45 -05:00
See also the list of [contributors](https://github.com/miguel5612/MQSensorsLib/contributors) who participated in this project.
2019-04-17 10:51:56 -05:00
## License
This project is licensed under the MIT License - see the [LICENSE.md](LICENSE.md) file for details
2019-09-02 19:40:02 -05:00
## Cite as
2019-09-02 20:00:44 -05:00
* 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": "<p>Publishing on Zenodo platform as software in order to extend its applications for other works allowing to recognize MQSensorLib&#39;s Authors this work into scientific community using Digital Object Identifier System (DOI).</p>",
"author": [
{
"family": "Califa Urquiza, Miguel Angel"
},
{
"family": "Contreras Contreras, Ghiordy"
},
{
"family": "Carrillo Amado, Yerson Ramiro"
}
],
"version": "1.0.3",
"type": "article",
"id": "3384301"
}
2019-09-02 19:40:02 -05:00
* BibTeX:
2019-09-02 20:00:44 -05:00
@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},
2019-09-02 19:40:02 -05:00
month = sep,
year = 2019,
2019-09-02 20:00:44 -05:00
doi = {10.5281/zenodo.3384301},
url = {https://doi.org/10.5281/zenodo.3384301}
2019-09-02 19:40:02 -05:00
}