Monitor de poluição portátil baseado em Arduino com display OLED

Arduino based portable pollution monitor with OLED display

Most middle-aged people suffer from health problems such as asthma and respiratory problems, especially in cities. Air pollution is the main cause of this. In this project, we designed a portable device that detects different air pollution metrics and displays them on a small OLED screen. People with respiratory problems can use the device to monitor pollution-related metrics and avoid dangerous places. The concept of this device can be integrated into consumer devices such as a smartwatch or a fitness watch.

In this project, the device is prototyped on Arduino. There are three air pollution metrics – CO2 level, smoke and dust – that are measured using the device. The level of CO2, smoke particles and dust density are measured using optical dust sensors MQ-135, MQ-2 and GP2Y1010AU0F. All metrics are displayed on a 128×64 SSD1306 OLED display.

Required components

  1. Arduino UNO x1
  2. Sensor MQ-2 x1
  3. Sensor MQ-135 x1
  4. Optical dust sensor GP2Y1010AU0F x1
  5. Resistance 150Ω x1
  6. SSD1306 x1 OLED screen
  7. Breadboard x1
  8. Connection wires/jumper wires

MQ-135 sensor

MQ-135 is an air quality sensor. It can be used to detect CO2, nitrogen oxide, benzene, NH3, smoke and alcohol. The sensor's load resistance can be adjusted to detect a particular gas, smoke or alcohol. In this project, the MQ-135 sensor is used to detect the CO2 level of the surrounding air. For this, the load resistance in the sensor circuit is set to 22KΩ.

MQ135 Sensor

MQ135 Sensor Example

For air quality measurement, the MQ-135 sensor needs to be preheated in clean air. After preheating for 24 hours, the value of R 0 can be determined. The MQ-135 air quality sensor has four pins – VCC, GND, Dout and Aout. To preheat the sensor, connect VCC to the Arduino's 5V output, GND to the Arduino's ground pin, and Aout to any Arduino's analog input pin, such as A4 in this project. These circuit connections are demonstrated below.

Preheating the MQ135 in clean air

Circuit for preheating the MQ135 sensor

Load the Arduino Sketch-1 onto the board and leave it for 24 hours. Then check the R 0 value of the serial monitor and disassemble the circuit. When building this project, the value of R 0 was found to be 929.15Ω.

Arduino Sketch 1 (for MQ-135 preheat)

#include “MQ135.h”
null configuration {
Serial.begin (9600);
}
empty loop {
Gas sensor MQ135 = MQ135(A4);
float rzero = gasSensor.getRZero;
Serial.println(rzero);
delay(1000);
}

MQ-2 sensor

MQ-2 is also a gas sensor. It can be used to detect concentrations of LPG, alcohol, hydrogen, methane, propane and carbon monoxide between 200 PPM and 1000 PPM. It is a metal oxide semiconductor (MOS) sensor. It works by changing its resistance when gas comes into contact with it. A voltage divider circuit detects the change in resistance. The sensor operates at 5V DC and consumes 800 mW of power. The sensor has four pins – VCC, GND, D0 and A0. VCC must be connected to the Arduino's 5V output and GND to the Arduino's ground pin. D0 pin can be connected to any GPIO. It can be calibrated to provide a LOW output for a threshold gas concentration level set by a potentiometer in the MQ-2 sensor circuit. A0 can be connected to any Arduino analog input pin and provides the gas concentration value in parts per million (PPM) as a voltage reading. The Arduino 10-bit analog reading is directly proportional to the gas concentration in PPM.

MQ2 gas sensor

Example of MQ2 gas sensor

In this project, the MQ-2 is used to detect smoke particles. The sensor module used in this project has a load resistance of 20K and is calibrated to directly emit a voltage proportional to the smoke level. According to the following graph, a simple MQ-2 sensor can be calibrated to detect different gases using a ratio of detection resistance to zero resistance.

Sensitivity characteristics of the MQ2 gas sensor

Sensitivity characteristics of the MQ2 gas sensor

Optical dust sensor GP2Y1010AU0F

The GP2Y1010AU0F optical dust sensor is used to detect the density of dust in the air. It consists of an IR diode and a photosensor mounted diagonally in an air inlet. When air containing dust particles enters the inlet, the dust particles scatter infrared radiations from the diode toward the photosensor. The greater the dust density, the more infrared light is scattered and the higher the photosensor output voltage. The GP2Y1010AU0F sensor can detect dust particles as small as 0.5um and dust density up to 0.580 mg/m 3 .

SSD1306 OLED screen

SSD1306 OLED display example

The GP2Y1010AU0F optical dust sensor has a six-pin connector with the following pin configuration.

SSD1306 OLED screen

SSD1306 is a popular OLED display. It is a single-chip CMOS OLED/PLED driver. It can manage a 128×64 dot matrix graphical display. It is designed to control common cathode OLED panels. The chip has several built-in features such as 256-step brightness control, display RAM, oscillator, and contrast control. These built-in features reduce the external components required and make the chip ready for use with any supported resolution OLED display.

SSD1306 OLED screen

SSD1306 OLED display example

In this project, we are using a 0.96″ OLED display with SSD1306 controller IC. The module has a Yellow-Blue screen with a screen resolution of 128×64. The module used here has a 7-pin interface, allowing you to interface the module with Arduino using 3-wire SPI, 4-wire SPI, and I2C interface. The 4-wire SPI interface is the default interface option on the 7-pin module. The 7-pin OLED display has the following pin configuration.

Circuit Connections

To design this portable pollution monitor, MQ-135, MQ-2, GP2Y1010AU0F optical dust sensor and SSD1306 OLED display are interfaced with Arduino UNO.

In this project, a 7-pin SSD1306 OLED module interfaces with the Arduino UNO. The module is connected to the Arduino as follows.

To interface the GP2Y1010AU0F optical dust sensor with Arduino UNO, make the connections summarized in the table below.

To interface the MQ2 sensor, connect VCC to the Arduino's 5V output, GND to the Arduino's ground pin, and Aout to the Arduino's A2 analog input pin. For interfacing, the MQ135 sensor connects VCC to the Arduino's 5V output, GND to the Arduino's ground pin, and Aout to the Arduino's A1 analog input pin.

Arduino Sketch

How it works

The device designed in this project detects air quality by measuring the level of CO2, smoke and dust density. It displays the measured metrics on the 128*64 SSD1306 OLED display. To measure air quality, the MQ-135 sensor is used. The sensor is preheated for 24 hours to obtain the R 0 value. The header file uses the R0 value in the MQ-135 library. Once the actual R 0 is obtained, it will be replaced with the default values ​​in the MQ135.h file. The MQ135 library can be downloaded from this link. With a load resistance of 22KΩ, the MQ-135 sensor can be used to measure the CO 2 concentration in the air. The sensor is connected to the Arduino pin A1. The CO 2 concentration in the air is obtained using the getPPM function from the MQ135 library.

Sharp's GP2Y1010AU0F optical dust sensor is useful in detecting fine particles such as cigarette smoke and dust particles in the air. The dust sensor measures dust density in mg/ m3 . Simultaneously, the dust density is also measured by the circuit.

At the same time, the MQ2 sensor is used to measure smoke particles. The density of smoke particles is measured in a range of 200 PPM to 1000 PPM. The sensor's analog reading is directly proportional to the smoke density in PPM.

When the device is turned on, it starts displaying the EEWORLDONLINE logo on the OLED display. Immediately after that, it starts reading the values ​​from all three sensors and displays the values ​​on the OLED display. Values ​​are updated every second.

Programming guide

The Arduino sketch starts with importing libraries for SPI communication and libraries required for SSD1306 OLED. The library for interfacing the SSD1306 with Arduino is available from Adafruit. To find it, navigate to the Arduino IDE's library manager, Sketch -> Add Library -> Manage Libraries. Search for SSD1306 and select the latest version of the Adafruit SSD1306 library. It will also download the GFX library as a dependency.

SSD1306 Library

SSD1306 library screenshot

The declaration of SSD1306-specific variables follows the inclusion of libraries for SSD1306. These variables store the SSD1306 specific constant values ​​and pin assignment. A bitmap object is stored in the Arduino PROGMEM to store the EEWORLDONLINE logo.

This is followed by defining the RLoad and RZero constants for the MQ-135 sensor and including the MQ-135 library. This MQ-135 library can be downloaded as a Zip file from this link and can be imported by navigating to Sketch->Add Library -> add .Zip library. Variables are declared to store sensor values ​​and pin assignment for dust sensor, MQ-135 sensor and MQ-2 sensor.

A drawbm function is defined to show the EEWORLDONLINE logo on the SSD1306 OLED display. In the setup function, the baud rate for serial communication is set to 9600 as all pollution metrics are also communicated to the serial port for observation. The SSD1306 OLED display is started by calling display. Begin function, and the EEWORLDONLINE logo is displayed on the screen. The MQ135 sensor pin is defined as input and the pin that connects to the dust sensor LED is defined as output. The analog pin-connected MQ-2 sensor is also defined as input.

In the loop function, firstly the dust level is calculated. The IR diode is turned on for 280 microseconds to measure the dust level and the photosensor output voltage is read. It takes about 40 to 50 microseconds to read the output voltage of the dust sensor, so a delay of 40 microseconds is provided. According to the GP2Y1010AU0F datasheet, the IR diode is pulsed every 10 milliseconds, so there are still 9.68 milliseconds left. The dust level is calculated using the following equations and printed on the Serial Monitor.

calcTension = vMeasured*(5.0/1024);
dust density = 0.17*calcVoltage-0.1;

Then, the analog reading from the MQ-135 sensor is obtained and the value of CO 2 concentration in PPM is calculated. In the same way, the analog reading of the MQ-2 sensor is obtained and the smoke density value in PPM is directly obtained. All pollution metrics are communicated to the serial monitor and also displayed on the OLED screen.

It should be noted that to display string values ​​on OLED display, display.write function is used, while to display sensor values ​​(numeric values), display.the print method is used. A 1000 millisecond delay is provided to repeat the metrics update every second.

Result

Conteúdo Relacionado

ESP32-CAM is a compact camera module that combines the...
A network of sensors is embedded in every vehicle,...
The motor controller is one of the most important...
A evolução dos padrões USB foi fundamental para moldar...
A SCHURTER anuncia um aprimoramento para sua conhecida série...
A Sealevel Systems anuncia o lançamento da Interface Serial...
A STMicroelectronics introduziu Diodos retificadores Schottky de trincheira de...
Determinar uma localização precisa é necessário em várias indústrias...
O novo VIPerGaN50 da STMicroelectronics simplifica a construção de...
A Samsung Electronics, fornecedora de tecnologia de memória avançada,...
O mercado embarcado tem uma necessidade de soluções de...
You have probably come across the term ' drag...
You probably have a support insulator if you've noticed...
You've probably seen stand an insulator sit on power...
You've probably seen shackle insulators enthroned on electricity poles,...
You have probably experienced situations where controlling a circuit...
Back to blog

Leave a comment

Please note, comments need to be approved before they are published.