Introduction: Air Quality Monitor

Project No.01(Room Automation)

Air Quality Checker

Displays the temperature and Relative Humidity(RH)

My inspiration for this project was my room automation where I automate my room making things more efficient, and useful aspects for safety.

The quality sensor employed in this project not only assesses air quality but also incorporates the functionality to measure room temperature and humidity utilizing the DHT11 sensor. The collected data is then visually presented on an OLED display, offering a comprehensive overview of the environmental conditions. This versatile device serves as an engaging and enlightening project, combining the elements of air quality monitoring with temperature and humidity measurements. Beyond its recreational aspects, the gadget proves to be exceptionally practical, providing valuable insights into the overall comfort and well-being of the surroundings.


In addition to its primary features, the project showcases the seamless integration of diverse sensors to create a compact and user-friendly solution. The OLED display not only enhances the visual appeal but also ensures convenient access to real-time data. This innovative combination of air quality, temperature, and humidity monitoring makes the device an informative tool for various settings, from homes and offices to educational environments. As an educational endeavor, it not only promotes understanding of sensor technology but also highlights the significance of environmental monitoring in our daily lives.




Supplies

DHT11 Temperature & Humidity Sensor

Air Quality sensor (MQ2 gas sensor) 

Arduino UNO 

OLED(0.96" i2c)

Jumper Wires 

Breadboard 

Arduino IDE

Step 1: Wiring

DHTxx Humidity and Temperature Sensor:

Role: Measures the ambient humidity and temperature.

Why it's there: Provides data on environmental conditions, which can be crucial for understanding air quality and making correlations between temperature, humidity, and gas concentrations.


MQ2 Gas Sensor:

Role: Detects various gases in the air, such as methane, carbon monoxide, and smoke.

Why it's there: Monitors the presence of harmful gases to assess air quality and provide early warnings in case of gas leaks or poor indoor air quality.


OLED Display:

Role: Displays the real-time data, such as temperature, humidity, and gas concentrations.

Why it's there: Allows users to easily read and interpret the information gathered by the sensors, providing a user-friendly interface for monitoring air quality.


Arduino Microcontroller:

Role: Acts as the brain of the system, processing data from sensors and controlling the display.

Why it's there: Coordinates the functions of the sensors, collects data, and sends information to the display for real-time monitoring. It essentially serves as the central control unit for the air quality monitor.





  1. Humidity and Temperature Sensor (DHTxx) to Arduino:
  • D2 (Digital Pin) on Arduino to Data Pin on DHTxx: This is where you connect the digital output pin (D2) of the Arduino to the data pin of the humidity and temperature sensor.
  • VCC on DHTxx to Power (5V) on Arduino: Connect the VCC pin of the sensor to the 5V power output on the Arduino.
  • GND on DHTxx to Ground (GND) on Arduino: Connect the ground (GND) pin of the sensor to the ground pin on the Arduino.
  1. MQ2 Gas Sensor to Arduino:
  • Ao (Analog Output) on MQ2 to Analog Pin A0 on Arduino: Connect the analog output pin (Ao) of the MQ2 gas sensor to analog pin A0 on the Arduino.
  • VCC on MQ2 to Power (5V) on Arduino: Connect the VCC pin of the sensor to the 5V power output on the Arduino.
  • GND on MQ2 to Ground (GND) on Arduino: Connect the ground (GND) pin of the sensor to the ground pin on the Arduino.
  1. OLED Display to Arduino:
  • SCL (Serial Clock) on OLED to Analog Pin A5 on Arduino: Connect the SCL pin of the OLED display to analog pin A5 on the Arduino.
  • SDA (Serial Data) on OLED to Analog Pin A4 on Arduino: Connect the SDA pin of the OLED display to analog pin A4 on the Arduino.
  • VCC on OLED to Power (5V) on Arduino: Connect the VCC pin of the OLED display to the 5V power output on the Arduino.
  • GND on OLED to Ground (GND) on Arduino: Connect the ground (GND) pin of the OLED display to the ground pin on the Arduino.

I used a breadboard power rail to distribute power and ground to all the components instead of directly into Arduino.

Step 2: Setup the Arduino

Prepare Arduino as Programmer:


Ensure USB Connection: Leave the Arduino board connected to the computer via USB.

Verify Arduino Connections:


Physical Wiring Check: Double-check the physical wiring between the Arduino and connected components to guarantee proper connectivity.


Board and Port Verification: In the Arduino IDE, navigate to "Tools" > "Board" and confirm the accurate selection of the board model. Additionally, verify the appropriate port under "Tools" > "Port" to ensure compatibility and successful communication.


Power Supply Inspection: Confirm the power supply to the Arduino and connected components, ensuring stable and adequate power levels for proper functionality.


Component Integrity Check: Inspect the integrity of connected components, including sensors, actuators, or any additional modules, to prevent potential issues during the project execution.


Firmware Compatibility: Verify that the firmware or sketches uploaded to the Arduino are compatible with the selected board and components, avoiding conflicts that may arise during the operation.


Driver Installation: Ensure that the necessary drivers for the Arduino board and any additional modules are correctly installed on the computer to facilitate seamless communication.


Grounding and Shielding: Pay attention to grounding and shielding practices to minimize electromagnetic interference and ensure signal stability throughout the connected components.


Serial Monitor Setup: If utilizing the Serial Monitor, configure the settings appropriately to monitor and debug communication between the Arduino and external devices.


Advanced Configuration (if applicable): For advanced projects, review and configure specific settings such as interrupts, timers, or communication protocols according to the project requirements.


Maintain a thorough and systematic approach to these preparatory steps to optimize the performance and reliability of your Arduino-based project.

Step 3: Code and Test Video


Libraries

The code includes several libraries:

SPI.h: Provides support for SPI communication.

Wire.h: Allows communication over the I2C protocol.

Adafruit_GFX.h: A graphics library for various displays.

Adafruit_SSD1306.h: A library for controlling OLED displays.

Fonts/FreeSans9pt7b.h and Fonts/FreeMonoOblique9pt7b.h: Font files for the OLED display.

DHT.h: A library for the DHT11 humidity and temperature sensor.

The primary functions within the code are denoted as sendSensor() and air_sensor(). In the air_sensor() function, the analog value from the Air quality sensor is acquired through the statement gasLevel = analogRead(sensor);, and the corresponding gas quality is defined based on this analog value. Conversely, the sendSensor() function utilizes the DHT library to measure temperature and humidity data, subsequently displaying it on the OLED.


It is essential to acknowledge that in the air_sensor() function, it may be necessary to condition the gasLevel value from the sensor. To achieve this, apply a 5V power supply to the MQ135 sensor, placing it in a pristine environment for a minimum of 24 hours before utilization. This process, often referred to as "burning," is imperative for this sensor type, as it facilitates self-cleaning and enhances result accuracy.


Following the burning process, connect the sensor to your circuit and position it outdoors. Calibrate the sensor to obtain the accurate value for your specific location. This meticulous calibration procedure ensures optimal functionality and precision in capturing environmental data.