🌫 Air quality assessment with Arduino

🌫 Air quality assessment with Arduino

Daniil Zhuk

Every year with the development of technology increases the comfort of a person on Earth. Only such benefits can include not only the widespread use of smart devices but also the natural needs of man. For example, the need for clean air.

Those who have been to the mountains will surely remember what fresh air is there. It is especially good to live on the shore of the lake and breathe aromatic herbs, flowering plants, in other words, nature. In the polluted atmosphere of megalopolises, you hardly find it all, but you can get serious health problems.

With the help of an Arduino and a special sensor, we can evaluate the air quality in the room or environment where we regularly spend time, compare with acceptable values ​​and take action.

Thanks to such devices, we can take control of the pollution situation under our control and protect ourselves.

In order to make it clear what you breathe, we need a special gas sensor MQ-135

This sensor allows you to detect gases such as smoke, ammonia, gasoline, alcohol, and others in the air. In the circuit, it is a semiconductor device, and its sensitivity is based on the change in the resistance of a small layer of tin dioxide in the so-called sensitive layer. There is also a small heating element in the sensor that heats the layer to the desired temperature in order to react to a certain gas. Due to the presence of a heater, the sensor is able to heat up significantly and in general, it is desirable for it to connect external power.

It is powered by a voltage of 5 volts, like most of the sensors on the Arduino. Connects to three contacts. These are grounding and power contacts, as well as a control contact (this can be both analog and digital output)

You can see the connection diagram below:

Measures the content of certain gases in the air (methane, hydrogen, propane, etc.) in terms of ppm - (millionth part) unit of concentration.

There is also a specific measurement range.

For example, for ammonia it is 10ppm-300ppm; for gasoline 10ppm-1000ppm; for alcohol 10ppm-300ppm.

Full datasheet on the sensor is here

Based on these data, it is possible to determine the normal concentration or higher.

Here is a sign of the maximum permissible concentration of gases in the air:

 Maximum permissible concentrations of harmful substances in the air

Name Maximum single (mg / m3) Daily average (mg / m3) In production areas (mg / m3) 
Carbon monoxide 3,0 1,0 20
Non-toxic dust 0,5 0,1 20
Hydrogen chloride 0,2 0,2 50
Ammonia 0,2 0,2 20
Chlorine 0,1 0,03 5
Nitrogen oxide 0,085 0,085 5
Sulfur oxide 0,03 0,005 10
Hydrogen sulfide 0,008 0,008 10

Let's deal with ammonia. First, we look at the units of measurement. In the table, it is mg / m3. The ppm value is measured in mg / l or mg / dm3
So 0.2 mg / m3 is 200 mg / dm3 or 200 ppm.
This means that the ammonia content in the air is more than 200 ppm is dangerous for a person, and our sensor will be able to safely fix and measure this.
Now we will load the following program code into the board:

const int analogSignal = A0; 
const int digitalSignal = 8;
boolean noGas; 
int gasValue = 0; 

void setup() {
  pinMode(digitalSignal, INPUT);

void loop() {
  noGas = digitalRead(digitalSignal); 
  gasValue = analogRead(analogSignal); 

  Serial.print("There is ");
  if (noGas) Serial.print("no gas");
  else Serial.print("gas");
  Serial.print(", the gas value is ");

The example demonstrates the connection of the sensor and the output of the received data to the serial port monitor

This article comes to an end. I wish you all a successful compilation and see you soon!

Add a comment

* Comments must be approved before being displayed.