MQ-X Arduino Library 1.0.0
This is a library for the MQ-X Sensors.
Loading...
Searching...
No Matches
MQ-Sensor-SOLDERED.h
Go to the documentation of this file.
1
11
12#ifndef __MQ_SENSOR__
13#define __MQ_SENSOR__
14
15#include "Arduino.h"
17#include "sensorConfigData.h"
18
19#ifdef __AVR__
20
21#define VOLTAGE_RES 5
22#define ADC_RES 10
23
24#elif ESP32
25
26#define VOLTAGE_RES 3.3
27#define ADC_RES 12
28
29#elif ESP8266
30
31#define VOLTAGE_RES 3.3
32#define ADC_RES 10
33#endif
34
35
37{
38 public:
39 MQ_Sensor(int _aPin, int _dPin, String type, sensorType sType) : MQUnifiedsensor(_aPin, "Arduino", VOLTAGE_RES, ADC_RES, type)
40 {
41 if (_aPin == -1)
42 {
43 native = 0;
45 setADC(10);
46 }
47 else
48 {
49 aPin = _aPin;
50 dPin = _dPin;
51 }
52 sensor_type=sType;
53 }
54
55 void begin();
56 void begin(sensorType configcustom);
57 bool begin(int _addr);
58 bool begin(int _addr, sensorType configcustom);
59 void setRegressionModel(const sensorType& type);
60 bool calibrateSensor(int numOfCalibrations);
61 bool digitalRead();
62
63 private:
64 void setConfiguration(sensorType &type);
65 int aPin, dPin;
67
68
69};
70
71class MQ2 : public MQ_Sensor
72{
73 public:
74 MQ2(int aPin = -1, int dPin = -1, sensorType sType=MQ2_config ) : MQ_Sensor(aPin, dPin, "MQ-2", sType)
75 {
76 }
77};
78
79class MQ3 : public MQ_Sensor
80{
81 public:
82 MQ3(int aPin = -1, int dPin = -1, sensorType sType=MQ3_config ) : MQ_Sensor(aPin, dPin, "MQ-3", sType)
83 {
84 }
85};
86
87class MQ4 : public MQ_Sensor
88{
89 public:
90 MQ4(int aPin = -1, int dPin = -1, sensorType sType=MQ4_config ) : MQ_Sensor(aPin, dPin, "MQ-4", sType)
91 {
92 }
93};
94
95
96class MQ5 : public MQ_Sensor
97{
98 public:
99 MQ5(int aPin = -1, int dPin = -1, sensorType sType=MQ5_config ) : MQ_Sensor(aPin, dPin, "MQ-5", sType)
100 {
101 }
102};
103
104class MQ6 : public MQ_Sensor
105{
106 public:
107 MQ6(int aPin = -1, int dPin = -1, sensorType sType=MQ6_config ) : MQ_Sensor(aPin, dPin, "MQ-6", sType)
108 {
109 }
110};
111
112class MQ7 : public MQ_Sensor
113{
114 public:
115 MQ7(int aPin = -1, int dPin = -1, sensorType sType=MQ7_config ) : MQ_Sensor(aPin, dPin, "MQ-7", sType)
116 {
117 }
118};
119
120class MQ8 : public MQ_Sensor
121{
122 public:
123 MQ8(int aPin = -1, int dPin = -1, sensorType sType=MQ8_config ) : MQ_Sensor(aPin, dPin, "MQ-8", sType)
124 {
125 }
126 private:
128};
129
130class MQ9 : public MQ_Sensor
131{
132 public:
133 MQ9(int aPin = -1, int dPin = -1, sensorType sType=MQ9_config ) : MQ_Sensor(aPin, dPin, "MQ-9", sType)
134 {
135 }
136};
137
138class MQ131 : public MQ_Sensor
139{
140 public:
141 MQ131(int aPin = -1, int dPin = -1, sensorType sType=MQ131_config ) : MQ_Sensor(aPin, dPin, "MQ-131", sType)
142 {
143 }
144};
145
146class MQ135 : public MQ_Sensor
147{
148 public:
149 MQ135(int aPin = -1, int dPin = -1, sensorType sType=MQ135_config ) : MQ_Sensor(aPin, dPin, "MQ-135", sType)
150 {
151 }
152};
153
154class MQ136 : public MQ_Sensor
155{
156 public:
157 MQ136(int aPin = -1, int dPin = -1, sensorType sType=Blank_config ) : MQ_Sensor(aPin, dPin, "MQ-136", sType)
158 {
159 }
160};
161
162class MQ137 : public MQ_Sensor
163{
164 public:
165 MQ137(int aPin = -1, int dPin = -1, sensorType sType=MQ137_config ) : MQ_Sensor(aPin, dPin, "MQ-137", sType)
166 {
167 }
168};
169
170class MQ138 : public MQ_Sensor
171{
172 public:
173 MQ138(int aPin = -1, int dPin = -1, sensorType sType=MQ138_config ) : MQ_Sensor(aPin, dPin, "MQ-138", sType)
174 {
175 }
176};
177
178class MQ214 : public MQ_Sensor
179{
180 public:
181 MQ214(int aPin = -1, int dPin = -1, sensorType sType=Blank_config ) : MQ_Sensor(aPin, dPin, "MQ-214", sType)
182 {
183 }
184};
185
186#endif
MQ131(int aPin=-1, int dPin=-1, sensorType sType=MQ131_config)
Definition MQ-Sensor-SOLDERED.h:141
MQ135(int aPin=-1, int dPin=-1, sensorType sType=MQ135_config)
Definition MQ-Sensor-SOLDERED.h:149
MQ136(int aPin=-1, int dPin=-1, sensorType sType=Blank_config)
Definition MQ-Sensor-SOLDERED.h:157
MQ137(int aPin=-1, int dPin=-1, sensorType sType=MQ137_config)
Definition MQ-Sensor-SOLDERED.h:165
MQ138(int aPin=-1, int dPin=-1, sensorType sType=MQ138_config)
Definition MQ-Sensor-SOLDERED.h:173
MQ214(int aPin=-1, int dPin=-1, sensorType sType=Blank_config)
Definition MQ-Sensor-SOLDERED.h:181
MQ2(int aPin=-1, int dPin=-1, sensorType sType=MQ2_config)
Definition MQ-Sensor-SOLDERED.h:74
MQ3(int aPin=-1, int dPin=-1, sensorType sType=MQ3_config)
Definition MQ-Sensor-SOLDERED.h:82
MQ4(int aPin=-1, int dPin=-1, sensorType sType=MQ4_config)
Definition MQ-Sensor-SOLDERED.h:90
MQ5(int aPin=-1, int dPin=-1, sensorType sType=MQ5_config)
Definition MQ-Sensor-SOLDERED.h:99
MQ6(int aPin=-1, int dPin=-1, sensorType sType=MQ6_config)
Definition MQ-Sensor-SOLDERED.h:107
MQ7(int aPin=-1, int dPin=-1, sensorType sType=MQ7_config)
Definition MQ-Sensor-SOLDERED.h:115
MQ8(int aPin=-1, int dPin=-1, sensorType sType=MQ8_config)
Definition MQ-Sensor-SOLDERED.h:123
sensorType sensor_type
Definition MQ-Sensor-SOLDERED.h:127
MQ9(int aPin=-1, int dPin=-1, sensorType sType=MQ9_config)
Definition MQ-Sensor-SOLDERED.h:133
int aPin
Definition MQ-Sensor-SOLDERED.h:65
sensorType sensor_type
Definition MQ-Sensor-SOLDERED.h:66
void begin()
Initializes the sensor with default configuration. Sets pin modes for analog and digital pins if they...
Definition MQ-Sensor-SOLDERED.cpp:71
bool digitalRead()
Reads the digital pin state of the sensor. Overloaded function for virtual in base class to initializ...
Definition MQ-Sensor-SOLDERED.cpp:102
bool calibrateSensor(int numOfCalibrations)
Calibrates the sensor by taking multiple readings and averaging them.
Definition MQ-Sensor-SOLDERED.cpp:136
MQ_Sensor(int _aPin, int _dPin, String type, sensorType sType)
Definition MQ-Sensor-SOLDERED.h:39
int dPin
Definition MQ-Sensor-SOLDERED.h:65
void setConfiguration(sensorType &type)
Configures the sensor with the given sensor type parameters.
Definition MQ-Sensor-SOLDERED.cpp:158
void setRegressionModel(const sensorType &type)
Sets the regression model parameters for the sensor based on given type.
Definition MQ-Sensor-SOLDERED.cpp:112
MQUnifiedsensor(int pin=1, String Placa="Arduino", float Voltage_Resolution=5, int ADC_Bit_Resolution=10, String type="CUSTOM MQ")
Definition MQUnifiedsensor.cpp:3
void setADC(int value)
Definition MQUnifiedsensor.cpp:35
bool native
Definition MQUnifiedsensor.h:48
void setVoltResolution(float voltage_resolution=5)
Definition MQUnifiedsensor.cpp:40
Header file that stores configuration data for each sensor type.
const struct sensorType MQ7_config
Definition sensorConfigData.h:142
const struct sensorType MQ8_config
Definition sensorConfigData.h:164
const struct sensorType MQ2_config
Definition sensorConfigData.h:32
const struct sensorType MQ138_config
Definition sensorConfigData.h:260
const struct sensorType MQ3_config
Definition sensorConfigData.h:55
const struct sensorType Blank_config
Definition sensorConfigData.h:272
const struct sensorType MQ137_config
Definition sensorConfigData.h:242
const struct sensorType MQ9_config
Definition sensorConfigData.h:184
const struct sensorType MQ5_config
Definition sensorConfigData.h:100
const struct sensorType MQ6_config
Definition sensorConfigData.h:121
const struct sensorType MQ135_config
Definition sensorConfigData.h:224
const struct sensorType MQ4_config
Definition sensorConfigData.h:77
const struct sensorType MQ131_config
Definition sensorConfigData.h:203
Definition sensorConfigData.h:15