Safeguarding your air, one breath at a time
Project by Saad Khan
Introduction
In Self sufficient building studio, we were instructed to take an old, functional electronic object and customize it to affect the climate on a micro scale and positive note using arduino circuitry and its components. The electronic object selected for this project was a SANDA brand aromatic diffuser, which has the potential to do more than make the room smell good, it can clean the air, make it breathable for people who are affected by pollution components such as dust or smoke ( mostly dust). Air pollution, particularly dust particles, poses significant health risks, including respiratory issues, allergies, and chronic illnesses.
Documentation of dismantling + info
After the disection of the device, a potential was found for this object to serve an additional purpose. The mist dissipated from the lid can trap and weigh down the air pollution particles such as dust from the air, making the air more breathable for people, making it a less hazard.
Image here, the neural function of the object. The center you will find is the PCB, being the brain of the device. The circuit has a capacitor ensuring smooth current flow, with a buzzer generating a sound when activated or signaling depletion of water within. The Pietzoplate ( white one on the top left) connected to the water container, generates 2.5 megahertz of frequency, converting the water to airborne water particles. The fan would assist in pushing the air borne water molecules out into the open. The LED strips , one with longer wires, are used to light up the rock salts for aesthetic purpose. The LED strip with short wires, is for lighting up the water contained in a specially designed container, which have two holes specially for the pietzaplate and fan.
The concept
Personally, the aim other than the primary objective was to maintain the device’s integrity, augment its circuitry, using relays that could be connected to the arduino circuit setup to detect pollution particles. The Arduino setup would have its own physical form, a semi open case, being a platform for the original device to stand on , as well as be connected to.
The documented drawings
The Setting up of Arduino board – The Air detector
Components such as Arduino Mega is recommended . Despite the use of the breadboard being the center of connections, it was theorized some of the components would require direct connection towards the Arduino circuit.
Its is recommended to use Tinkercad https://www.tinkercad.com/ to form connections to prevent short circuiting of the board. Minimum components are required ; Arduino mega, breadboard, jumpwires, 3 LED bulbs, 220 ohms resistors, a relay button and a MC-135 gas detector which can be programmed to detect air pollution particles.
Once your tinkercad circuit functions without risks, then resume augmenting the circuitry of the aromatic diffuser.
Before that, fabricate a physical body form the arduino circuitry. I manually fabricated it using 4 mm mdf board. The bread board is placed below the arduino board, which is placed upside down, connected using jump-wires.
The addition of the PCB circuitry
Relay components are required to form connections between the device’s fan and pietza plate and the fan.
The difficult part was was to adjust the circuitry back with two additional relays. One relay is connected to the Pietza plate, the other to the fan. In order to achieve the connection, the power wires need to be cut equally, then screwed to the relay to its respected positions. The relay component, would then be connected to the arduino board using jump wires. To shorten the distance between the relays and and arduino mega, holes were drilled at the back, where the wires would come out and connect to the detecting circuitry.
Merging the two to one unit – The Air-Guard
The circuitry of the diffuser connected to the arduino circuitry, can now be controlled using arduino and its code to be uploaded. The goal was to preserve the integrity of the original device’s form and give it a new purpose.
The code breakdown
1. Include the MQ-135 Sensor Library
#include <MQSensor.h>
- This includes the library for the MQ-135 sensor, which simplifies the process of reading sensor values and calculating pollutant levels in PPM (parts per million).
2. Pin Definitions
#define MQ135_PIN A2 // MQ-135 analog output connected to A2 #define RED_LED 8 // Red LED for poor air quality #define YELLOW_LED 9 // Yellow LED for moderate air quality #define GREEN_LED 10 // Green LED for good air quality #define FAN_RELAY_PIN 4 // Relay 1 (Fan) connected to D4 #define MIST_RELAY_PIN 5 // Relay 2 (Misting Module) connected to D5
- MQ135_PIN (A2): Reads analog output from the MQ-135 sensor.
- RED_LED, YELLOW_LED, GREEN_LED: Control LEDs that indicate air quality levels:
- Red: Poor air quality.
- Yellow: Moderate air quality.
- Green: Good air quality.
- FAN_RELAY_PIN, MIST_RELAY_PIN: Control relays for the fan and misting module, which activate based on air quality.
3. Initialize MQ-135 Sensor
MQSensor mq135(MQ135_PIN, 4.7);
- Creates an MQSensor object for the MQ-135.
- The second argument (
4.7
) is the load resistance of the sensor in kilo-ohms. This is a required parameter for calculations.
4. setup()
Function
This runs once when the Arduino starts and initializes all components.
Serial Monitor Initialization
Serial.begin(9600); Serial.println("-----------------------------------------"); Serial.println("Initializing MQ-135 Sensor..."); Serial.println("Calibrating R0... Please leave the sensor in clean air!");
- Starts the Serial Monitor for debugging.
- Prompts the user to leave the sensor in clean air for calibration.
Sensor Calibration
float r0 = mq135.calculateR0(100); Serial.print("Calibration Complete. R0: "); Serial.println(r0); Serial.println("-----------------------------------------");
- The
calculateR0()
function calculates the sensor’s baseline resistance (R0) in clean air. This is required for accurate PPM calculations. - The function runs 100 iterations to ensure calibration accuracy.
Pin Initialization
pinMode(RED_LED, OUTPUT); pinMode(YELLOW_LED, OUTPUT); pinMode(GREEN_LED, OUTPUT); pinMode(FAN_RELAY_PIN, OUTPUT); pinMode(MIST_RELAY_PIN, OUTPUT);
- Sets up the LED pins and relay pins as outputs so they can be controlled by the Arduino.
Initial State
digitalWrite(FAN_RELAY_PIN, HIGH); // Relay OFF digitalWrite(MIST_RELAY_PIN, HIGH); // Relay OFF digitalWrite(RED_LED, LOW); digitalWrite(YELLOW_LED, LOW); digitalWrite(GREEN_LED, LOW);
- Ensures:
- The relays are OFF (active LOW logic).
- All LEDs are turned off.
5. loop()
Function
This runs continuously after setup()
to monitor air quality and control devices.
Reading Air Quality
int ppm = mq135.readPPM(3.90719312430419, -1.99513126467406);
- Reads the PPM (parts per million) value from the MQ-135.
- Uses calibration constants (
3.907...
and-1.995...
) for accurate calculations.
Displaying Values
Serial.println("\n-----------------------------------------"); Serial.print("PPM: "); Serial.println(ppm); Serial.println("-----------------------------------------");
- Displays the PPM value on the Serial Monitor for debugging and observation.
6. Air Quality Thresholds
The script determines the air quality level based on the PPM value.
Poor Air Quality
if (ppm > 5000) { Serial.println("ALERT: Poor Air Quality!"); setLEDs(1, 0, 0); // Red LED on digitalWrite(FAN_RELAY_PIN, LOW); // Relay ON (Active LOW) digitalWrite(MIST_RELAY_PIN, LOW); // Relay ON (Active LOW) }
- Condition: If PPM is greater than 5000.
- Actions:
- Turns on the Red LED.
- Activates the fan and misting module by setting their relay pins to LOW (active LOW relays).
Moderate Air Quality
else if (5000 >= ppm > 400) { Serial.println("WARNING: Moderate Air Quality!"); setLEDs(0, 1, 0); // Yellow LED on deactivateRelays(); // Turn off fan and misting module }
- Condition: If PPM is between 400 and 5000.
- Actions:
- Turns on the Yellow LED.
- Turns off the fan and misting module.
Good Air Quality
else if (ppm <= 400) { Serial.println("STATUS: Good Air Quality."); setLEDs(0, 0, 1); // Green LED on deactivateRelays(); // Turn off fan and misting module }
- Condition: If PPM is less than or equal to 400.
- Actions:
- Turns on the Green LED.
- Turns off the fan and misting module.
7. Helper Functions
Deactivate Relays
void deactivateRelays() { digitalWrite(FAN_RELAY_PIN, HIGH); // Turn OFF fan (active LOW relay) digitalWrite(MIST_RELAY_PIN, HIGH); // Turn OFF misting module (active LOW relay) }
- Ensures the fan and misting module are turned off by setting the relay pins to HIGH.
Control LEDs
void setLEDs(int red, int yellow, int green) { digitalWrite(RED_LED, red); digitalWrite(YELLOW_LED, yellow); digitalWrite(GREEN_LED, green); }
- Turns LEDs ON/OFF based on the input parameters:
red
,yellow
,green
are either1
(ON) or0
(OFF).
How It Works Together
- Initialization:
- The MQ-135 sensor calibrates itself in clean air and sets the baseline resistance.
- LEDs and relays are initialized to the OFF state.
- Continuous Monitoring:
- The Arduino reads air quality in PPM every 2 seconds.
- Based on thresholds:
- Poor air quality activates the fan, misting module, and Red LED.
- Moderate air quality turns on the Yellow LED and keeps the fan and misting module off.
- Good air quality turns on the Green LED and keeps the fan and misting module off.
- Device Control:
- Relays are used to power the fan and misting module.
- LEDs provide a visual indication of air quality.
The faults that need addressing
The sensor circuitry works fine along with the relays , as the relays light up green when sensor sends data of air pollution. The main device however, activates and functions with an independent power supply, is active for only 3 seconds. When the relays are active the fan does activate, however the pietzaplate does not seem to serve its function. This will be addressed and hopefully be updated in the blog.