+#define READ_SAMPLE_INTERVAL 50
+#define READ_SAMPLE_TIMES 5
+
+#define MQ135_RES 1000
+
+float MQRead(int mq_pin)
+{
+
+ int i;
+ float rs=0;
+ float rr;
+
+ for (i=0;i<READ_SAMPLE_TIMES;i++) {
+ rr = analogRead(mq_pin);
+ rs += rr;
+ delay(READ_SAMPLE_INTERVAL);
+ }
+
+ rs = rs/READ_SAMPLE_TIMES;
+ return rs;
+
+}
+
+/// Parameters to model temperature and humidity dependence
+
+#define CORA 0.00035
+#define CORB 0.02718
+#define CORC 1.39538
+#define CORD 0.0018
+
+float getMQ135CorrectionFactor(float t, float h) {
+ return CORA * t * t - CORB * t + CORC - (h-33.)*CORD;
+}
+
+#define RZERO 25300
+#define PARA 116.6020682
+#define PARB 2.769034857
+
+float getMQ135ppm(float Resistance) {
+ return PARA * pow((Resistance/RZERO), -PARB);
+}
+