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

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