Sei sulla pagina 1di 3

hen comes the calibration process.

just calibrate it to get about 100-150 from


analogRead in a good air condition.

normal air returns ~100-150


alcohol returns ~700
lighter gas returns ~750+

The sketch is simple:

int sensorPin = A0;


int sensorValue = 0;
void setup() {
Serial.begin(9600);
pinMode(sensorPin, INPUT);
}
void loop() {
sensorValue = analogRead(sensorPin);
Serial.println(sensorValue);
}
It reads the sensor value and print it on Serial terminal.

Note that when sensor are power up they need about 1 minute to settle, in this time
the heater heats up the sensor.

We experimented with Isopropile alcohol, Benzine, Lighter Gas, human breath of two
different persons ??

Here is the measured data:

MQ-2 normal air output 100


Isopropile alcohol 540
Ligther Gas 760
Benzine 450
Breath1 150
Breath2 140
MQ-3 normal air output 180
Isopropile alcohol 800
Lighter Gas 400
Benzine 700
Breath1 220
Breath2 270

MQ-7 normal air output 150


Isopropile alcohol 750
Lighter Gas 900
Benzine 800
Breath1 170
Breath2 160
MQ-135 normal air output 130
Isopropile alcohol 700
Lighter Gas 760
Benzine 450
Breath1 150
Breath2 140
the results are:

MQ-2 shows good sensibility to Lighter Gas

MQ-3 detects well Isopropile alcohol and Benzine


MQ-7 detects well Isopropile alcohol, Lighter gas and Benzine

MQ-135 detects well Isopropile alcohol, Lighter gas

#include <DHT.h>

#define DHTTYPE DHT11

#include "MQ135.h"

// MQ135 gas sensor


//
// Datasheet can be found here:
https://www.olimex.com/Products/Components/Sensors/SNS-MQ135/resources/SNS-
MQ135.pdf
//
// Application
// They are used in air quality control equipments for buildings/offices, are
suitable for detecting of NH3, NOx, alcohol, Benzene, smoke, CO2, etc
//
// Original creator of this library: https://github.com/GeorgK/MQ135

DHT dht(5, DHTTYPE);

#define PIN_MQ135 A3
MQ135 mq135_sensor = MQ135(PIN_MQ135);

float temperature = 28.0; // assume current temperature. Recommended to measure


with DHT22
float humidity = 25.0; // assume current humidity. Recommended to measure with
DHT22

void setup() {
Serial.begin(9600);
}

void loop() {
float humidity = dht.readHumidity();
float temperature = dht.readTemperature();
if (isnan(humidity) || isnan(temperature))
{
Serial.println("Failed to read from DHT sensor!");
return;
}

float rzero = mq135_sensor.getRZero();


float correctedRZero = mq135_sensor.getCorrectedRZero(temperature, humidity);
float resistance = mq135_sensor.getResistance();
float ppm = mq135_sensor.getPPM();
float correctedPPM = mq135_sensor.getCorrectedPPM(temperature, humidity);

Serial.print("MQ135 RZero: ");


Serial.print(rzero);
Serial.print("\t Corrected RZero: ");
Serial.print(correctedRZero);
Serial.print("\t Resistance: ");
Serial.print(resistance);
Serial.print("\t PPM: ");
Serial.print(ppm);
Serial.print("\t Corrected PPM: ");
Serial.print(correctedPPM);
Serial.print("ppm @ temp/hum: ");
Serial.print(temperature);
Serial.print("/");
Serial.print(humidity);
Serial.println("%");
delay(600);
}

Potrebbero piacerti anche