First test compile OK

This commit is contained in:
miguel5612 2019-05-19 13:27:00 -05:00
parent e53a1b869f
commit 68b2440461
8 changed files with 70 additions and 189 deletions

Binary file not shown.

Binary file not shown.

Binary file not shown.

BIN
Release/19052019_Test1.zip Normal file

Binary file not shown.

12
examples/MQ4/MQ4.ino Normal file
View File

@ -0,0 +1,12 @@
#include <MQUnifiedsensor.h>
void setup() {
// put your setup code here, to run once:
}
void loop() {
// put your main code here, to run repeatedly:
}

10
library.properties Normal file
View File

@ -0,0 +1,10 @@
name=MQUnifiedsensor
version=1.0.0
author= Miguel Califa <miguelangel5612@gmail.com>, Yersson Carrillo <miguelangel5612@gmail.com>, Ghiordy Contreras <miguelangel5612@gmail.com>
maintainer= Miguel Califa <miguelangel5612@gmail.com>
sentence= This is a unified library to use sensors MQ: 2, 3, 4, 5, 6, 7, 8, 9, and 135.
paragraph= This is a unified library to use sensors MQ: 2, 3, 4, 5, 6, 7, 8, 9, and 135.
category= Sensor
url=https://github.com/miguel5612/MQSensorsLib
architectures=*
license=MIT

View File

@ -1,167 +1,36 @@
#include "MQUnifiedsensor.h"
MQUnifiedsensor::MQSensor(int pin) {
void MQUnifiedsensor::MQSensor(int pin, int type) {
this->_pin = pin;
this->_type = type; //2,3,4,5,6,7,8,9,131,135,303,309
}
MQUnifiedsensor::setR0(double R0) {
void MQUnifiedsensor::setR0(double R0) {
this->_R0 = R0;
}
/****************** Info of sensor graphic *******************/
//MQ-2 - Methane, Butane, LPG, smoke
//MQ-3 - Alcohol, Ethanol, smoke
//MQ-4 - Methane, CNG Gas
const float R0 = 11.820;
const float m = -0.318;
const float b = 1.133;
//MQ-5 - Natural gas, LPG
//MQ-6 - LPG, butane gas
//MQ-7 - Carbon Monoxide
//MQ-8 - Hydrogen Gas
//MQ-9 - Carbon Monoxide, flammable gasses
//MQ131 - Ozone
//MQ135 - Air Quality (CO, Ammonia, Benzene, Alcohol, smoke)
//MQ136 - Hydrogen Sulfide gas
//MQ137 - Ammonia
/****************** Info of sensor graphic *******************/
//***************** Operations ************************************/
int readMethane()
String MQUnifiedsensor::readSensor(String nameLectureReqeuired)
{
switch (_type)
{
case 1:
break;
default:
break;
}
}
int readButane()
void MQUnifiedsensor::getSensorCharacteristics(int MQ[38], String nameLectureReqeuired)
{
if(nameLectureReqeuired = nameLecture[0])
{
_m = MQ[indexSlopeLectures[0]];
_b = MQ[indexBPointLectures[0]];
}
}
int readLPG()
{
}
int readSmoke()
{
}
int readAlcohol()
{
}
int readEthanol()
{
}
int readCNG()
{
}
int readLPG()
{
}
int readCO()
{
}
int readHO()
{
}
int readCarbonMonoxide()
{
}
int readNH4()
{
}
int readbenzene()
{
}
int readAlcohol()
{
}
int readHidrogen()
{
}
int readToluene()
{
}
int readAcetone()
{
}
int readPropane()
{
}
int readCoalGas()
{
}
const float VOLT_RESOLUTION = 5.0; // if 3.3v use 3.3
const int ADC_RESOLUTION = 10; // for 10bit analog to digital converter.
const int retries = 50;
const int retry_interval = 20;
double MQUnifiedsensor::calibrate() {
float sensor_volt; //Define variable for sensor voltage
@ -189,7 +58,7 @@ double MQUnifiedsensor::getVoltage() {
/**
* Returns the PPM concentration
*/
int MQUnifiedsensor::read() {
int MQUnifiedsensor::readPPM(int m, int b) {
double sensor_volt = this->getVoltage();
double RS_gas; //Define variable for sensor resistance
double ratio; //Define variable for ratio
@ -201,4 +70,4 @@ double MQUnifiedsensor::getVoltage() {
double ppm_log = (log10(ratio) - b) / m; //Get ppm value in linear scale according to the the ratio value
double ppm = pow(10, ppm_log); //Convert ppm value to log scale
return floor(ppm);
}
}

View File

@ -1,7 +1,8 @@
#ifndef MQUnifiedsensor_H
#define MQUnifiedsensor_H
#define MQUnifiedsensor_H
#include <Arduino.h>
#include <stdint.h>
class MQUnifiedsensor
{
@ -9,9 +10,24 @@ class MQUnifiedsensor
/**
* Constructor
*/
MQSensor(int pin);
setR0(double R0);
setSensorTyp(int sensorNumber);
void MQSensor(int pin, int type);
void setR0(double R0);
void setSensorTyp(int sensorNumber);
void getSensorCharacteristics(int MQ[38], String nameLectureReqeuired);
String readSensor(String nameLectureReqeuired);
int readPPM(int m, int b);
/**
* Calibrates the start point of 400
*/
double calibrate();
/**
* Returns the voltage
*/
double getVoltage();
/**
* Returns the PPM concentration
MQ-2 - Methane, Butane, LPG, smoke
@ -48,40 +64,14 @@ class MQUnifiedsensor
int MQ303A[38] = {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,-2.3543,1.144,-2.4338,0.7558,-2.5597,0.4436};
int MQ309A[38] = {-2.1311,3.0886,0,0,-1.6554,2.985,-4.7623,6.7413,-3.7686,5.6744,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0};
int readMethane();
int readButane();
int readLPG();
int readSmoke();
int readAlcohol();
int readEthanol();
int readCNG();
int readLPG();
int readCO();
int readHO();
int readCarbonMonoxide();
int readNH4();
int readbenzene();
int readAlcohol();
int readHidrogen();
int readToluene();
int readAcetone();
int readPropane();
int readCoalGas();
/**
* Calibrates the start point of 400
*/
double calibrate();
/**
* Returns the voltage
*/
double getVoltage();
private:
int _pin;
double _R0;
int _pin, _type;
double _R0, _m, _b;
const float VOLT_RESOLUTION = 5.0; // if 3.3v use 3.3
const int ADC_RESOLUTION = 10; // for 10bit analog to digital converter.
const int retries = 50;
const int retry_interval = 20;
};
#endif //MQUnifiedsensor_H