-
Notifications
You must be signed in to change notification settings - Fork 63
/
MQUnifiedsensor.h
65 lines (54 loc) · 2.03 KB
/
MQUnifiedsensor.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
#ifndef MQUnifiedsensor_H
#define MQUnifiedsensor_H
#include <Arduino.h>
#include <stdint.h>
/***********************Software Related Macros************************************/
class MQUnifiedsensor
{
public:
MQUnifiedsensor(String Placa = "Arduino", float Voltage_Resolution = 5, int ADC_Bit_Resolution = 10, int pin = 1, String type = "CUSTOM MQ");
MQUnifiedsensor(String Placa = "Arduino", String type = "CUSTOM MQ");
//Functions to set values
void init();
void update();
void externalADCUpdate(float volt);
void setR0(float R0 = 10);
void setRL(float RL = 10);
void setA(float a);
void setB(float b);
void setRegressionMethod(int regressionMethod);
void setVoltResolution(float voltage_resolution = 5);
void setPin(int pin = 1);
void serialDebug(bool onSetup = false); //Show on serial port information about sensor
void setADC(int value); //For external ADC Usage
//user functions
float calibrate(float ratioInCleanAir);
float readSensor(bool isMQ303A = false, float correctionFactor = 0.0, bool injected=false);
float readSensorR0Rs();
float validateEcuation(float ratioInput = 0);
//get function for info
float getA();
float getB();
float getR0();
float getRL();
float getVoltResolution();
String getRegressionMethod();
float getVoltage(bool read = true, bool injected = false, int value = 0);
float stringTofloat(String & str);
// functions for testing
float getRS();
float setRsR0RatioGetPPM(float value);
private:
/************************Private vars************************************/
byte _pin = 1;
byte _firstFlag = false;
float _VOLT_RESOLUTION = 5.0; // if 3.3v use 3.3
float _RL = 10; //Value in KiloOhms
byte _ADC_Bit_Resolution = 10;
byte _regressionMethod = 1; // 1 -> Exponential || 2 -> Linear
float _adc, _a, _b, _sensor_volt;
float _R0, RS_air, _ratio, _PPM, _RS_Calc;
char _type[7];
char _placa[20];
};
#endif //MQUnifiedsensor_H