Portable Air Quality Meter
Hello everyone, and welcome back! Today, I have something incredibly useful for you—a Portable Air Quality Meter.
The Portable Air Quality Meter allows the user to monitor air quality using the MQ135 sensor and visually display the readings on the OLED display using the FireBeetle ESP32 E V1.
Because of its small size and built-in power supply, the user can gather air quality readings anywhere they go.
The concentration of specific gases in the air is indicated by this air quality meter, however it is not the same as a complete Air Quality Index (AQI) evaluation. Initially particulate matter (PM2.5 and PM10), oxygen, nitrogen dioxide, sulfur dioxide, and carbon monoxide are commonly monitored in air quality index monitoring. The only gases that our setup can detect are CO2, smoking, benzene, alcohol, nitrogen oxide, and ammonia.
The thorough and standardized AQI used for public health advisories is still the best source of information, but our air quality meter is a terrific tool for gaining a general understanding of the air quality in terms of specific gases.
The inside components of this project include the MQ135 Air Quality Sensor, the SSD1306 Display, a tiny 14500 3.7V 600mAh Li-ion cell, and the Firebeetle 2 ESP32 Microcontroller, which serves as the project's brain. All of these components come together in a customized body that we 3D printed.
Let us begin the build since this article covers the entire meter's construction process.
Materials required
These are the materials used in this build-
- MQ135 Air Quality Sensor (Got from PCBWAY GIFTSHOP)
- Raspberry Pi PICO 2
- BREADBOARD
- 3D-PRINTED BODY
- 14500 3.7V 600mAh Li-ion cell with PCM
- ROCKER SWITCH SPST
- FireBeetle 2 ESP32-E DEV BOARD
- SSD1306 OLED SCREEN
- connecting wires
- M2 Screws
MQ135 Air Quality Sensor
The MQ135 sensor finds numerous applications in pollution control, environmental monitoring, and air quality monitoring systems. It can be included into many projects to monitor air quality and is appropriate for detecting dangerous gases in the atmosphere.
Two outputs are available: an analog output that generates an analog voltage signal (0–5V) based on the gas concentration and a digital signal (0V or 5V) based on a gas concentration beyond a threshold. It runs from a 3.3V supply but can withstand 5V max.
The sensor needs to be preheated for 20 seconds in order to stabilize and provide accurate readings, and it uses 150 mA when in use.
Ammonia (NH3), nitrogen oxides (NOx), carbon dioxide (CO2), benzene, smoke, and other dangerous gases can all be detected with this sensor.
PCBWAY GIFTSHOP
As for sourcing the MQ135 sensor along with the OLED display and PICO 2 we used in this project, we got them from PCBWAY's Giftshop.
https://www.pcbway.com/project/gifts_detail/MQ135_air_quality_sensor_module.html
https://www.pcbway.com/project/gifts_detail/Raspberry_Pi_Pico_2_a84bd81f.html
https://www.pcbway.com/project/gifts_detail/0_96_Inch_Oled_Screen.html
PCBWAY gift shop is an online marketplace where you can get a variety of electronics modules and boards for their genuine price, or you could use the PCBWAY currency, which is called beans.
You get beans after ordering something from PCBWAY as reward points, or you can also get them by posting any project in the PCBWAY community.
Also, PCBWay is hosting its 7th Project Design Contest, a global competition that invites electronics enthusiasts, engineers, and makers to showcase their innovative projects. The contest provides a platform for participants to share their creativity and technical expertise with the broader community.
This year’s competition includes three major categories: electronic project, mechanical project and SMT 32 project
With prizes awarded for the most exceptional designs, the contest aims to inspire and support innovation, making it an exciting opportunity for both professionals and hobbyists to gain recognition and connect with like-minded creators.
You guys can check out PCBWAY if you want great PCB service at an affordable rate.
Basic Setup using Raspberry Pi Pico
We begin by putting together the simplest possible configuration utilizing the MQ135 Sensor and the recently released Raspberry Pi PICO 2.
Here, we connected the MQ135 Sensor's VCC to the 3.3V Pin of PICO, GND to GND, and GPIO26 and GPIO21 for the analog and digital outputs, respectively.
This was the sketch we used for Test.
#include <Wire.h> // Define the pins const int analogPin = 26; // GP26 const int digitalPin = 21; // GP21 void setup() { Serial.begin(9600); pinMode(digitalPin, INPUT); } void loop() { int analogValue = analogRead(analogPin); int digitalValue = digitalRead(digitalPin); Serial.print("Analog Value: "); Serial.print(analogValue); Serial.print(", Digital Value: "); Serial.println(digitalValue); delay(1000); }
It takes about 20 to 30 seconds for the MQ135 Sensor to preheat before it provides precise readings. The sensor value in the Serial monitor can be observed by the user using the sketch above.
Level 2- Design
We made a little enclosure in the Level 2 design that was just 80 x 55 x 30 mm in size. It was separated into two bodies: the Base and the Top Lid part. The OLED screen is mounted in place by the top lid, which also has four screw holes for attaching it to the base body with M2 screws.
The Firebeetle 2 Board, MQ135 Sensor, Power Switch, and Battery are all housed inside the Base Body.
We added handles to the left and right sides of the base body to make this enclosure comfortable and easy to hold.
To make it easier to wear or carry around, we have included a hook-like component that can be used to attach an ID card strap or a keychain to this device.
We created additional components that resemble the letters O and X and put them on the top lid part of the enclosure to increase its visual impact. To enhance the device's aesthetic impact, both of these parts will be printed in orange PLA, while the entire enclosure will be printed in grey PLA.
Why Choose FireBeetle over Raspberry Pi Pico
For level 2 of this project, we swapped the main microcontroller used, which was the Raspberry Pi Pico 2, to the Firebeetle 2 ESP32-E Microcontroller board.
A minor space issue within the enclosure was the reason for this switch; however despite the fact that the two boards appear to be almost identical in size, the Pico is really smaller than the Firebeetle. We had to modify the enclosure's design and make it slightly larger because using Pico required the addition of a second board for charging the lithium cell.
We utilized the Firebeetle to address this issue since it has an onboard lithium-ion cell charging circuit that is driven by the TP4056, a full linear charger integrated circuit made specifically for single-cell lithium-ion batteries.
The TP4065 was incorporated into the Firebeetle development board, which resolved our space issue. It is perfect for usage in portable devices that need a dependable and effective lithium-ion battery charging solution.
MAIN SKETCH
Let's have a look at the final Sketch which will be used in Firebeetle Setup.
#include <Wire.h> #include <Adafruit_GFX.h> #include <Adafruit_SSD1306.h> #define SCREEN_WIDTH 128 #define SCREEN_HEIGHT 64 #define OLED_RESET -1 Adafruit_SSD1306 display(SCREEN_WIDTH, SCREEN_HEIGHT, &Wire, OLED_RESET); const int analogPin = 35; // A3 const int digitalPin = 2; // D2 void setup() { Serial.begin(9600); pinMode(digitalPin, INPUT); // SSD1306 OLED display initialization if (!display.begin(SSD1306_SWITCHCAPVCC, 0x3C)) { Serial.println(F("SSD1306 allocation failed")); for(;;); } display.display(); delay(2000); // Pause for 2 seconds display.clearDisplay(); } void loop() { int analogValueRaw = analogRead(analogPin); int analogValue = map(analogValueRaw, 0, 4095, 0, 1023); // Scale the value to match the Pico's range int digitalValue = digitalRead(digitalPin); String airQuality = getAirQuality(analogValue); Serial.print("Analog Value (Raw): "); Serial.print(analogValueRaw); Serial.print(", Scaled Value: "); Serial.print(analogValue); Serial.print(", Digital Value: "); Serial.println(digitalValue); // Display scaled analog value and air quality condition on OLED display.clearDisplay(); display.setTextSize(2); // Normal 1:1 pixel scale display.setTextColor(SSD1306_WHITE); // Draw white text display.setCursor(0, 10); // Start at top-left corner display.print("Value: "); display.println(analogValue); display.setTextSize(1); display.setCursor(0, 40); display.print("Air Quality: "); display.println(airQuality); display.display(); delay(1000); } String getAirQuality(int analogValue) { if (analogValue <= 200) { return "Excellent"; } else if (analogValue <= 400) { return "Good"; } else if (analogValue <= 600) { return "Moderate"; } else if (analogValue <= 800) { return "Poor"; } else { return "Very Poor"; } }
The three main libraries in the sketch were added specifically to use I2C communication to drive the SSD1306 OLED.
Two outputs are provided by the MQ135 sensor: an analog output that is attached to the Firebeetle's A3 pin and a digital output that is connected to the Firebeetle's D2.
We must reduce the raw analog value, which is around 0-4095, to a range of 0-1023 in order to obtain the analog value, which is what we need to obtain the air quality measurements.
Using the Serial.println function, the values are displayed on the screen, but with a twist. The twist here is that we have added getAirQuality Function which takes the scaled analog value and returns a string representing the air quality condition:
- <= 200: "Excellent"
- <= 400: "Good"
- <= 600: "Moderate"
- <= 800: "Poor"
- > 800: "Very Poor"
FireBeetle SSD1306 Display and MQ135 Wiring
If you are recreating this project, it will be easier for you because the wiring diagram for the entire procedure has been added.
- Connecting the Firebeetle's 3.3V and GND wire to the MQ135 Sensor's VCC and GND starts the procedure.
- Next, we used two wires to connect the Firebeetle's 5V and GND to the SSD1306 VCC and GND pins.
- Following that, we used connecting wires to link the MQ135 Sensor's analog and digital outputs to the Firebeetle's A3 and D2.
- Next, we linked the Firebeetle's SDA and SCL pins to the OLED screen's SDA and SCL pins in a similar manner.
Power Source Wiring
We are using a compact formfactor 14500 3.7V 600mAh Lithium ion cell combined with a Protection Circuit Module (PCM), a tiny circuit that guards against overcharge, overdischarge, short circuit, and other issues, as the project's power supply.
We simply connected the lithium cell's positive terminal to the firebeetle's battery positive terminal for the wiring. The negative of the lithium cell was soldered to the rocker switch's on terminal, and the other terminal of the rocker switch was connected to the firebeetle's battery negative terminal. The rocker switch, which is positioned between the battery and the firebeetle, serves as the device's primary power switch.
Body Assembly process
- We positioned the OLED screen inside the top lid to begin the body assembly process, and then we used hot glue to secure the display in place.
- Within the Base body, the MQ135 sensor is then slide into place.
- The battery and power switch are next fastened in their proper positions, and the Firebeetle Board is placed in the center of the base body and fastened there using hot glue.
- After ensuring that everything was in its proper place, we placed the top lid over the base body and fastened them together with four M2 screws.
- We finish by applying super glue to the back of the letter O and X parts before positioning them onto the device.
The assembly process is now complete.
Result and Conclusion
The Air Quality Meter, a portable air quality monitoring device that can measure hazardous gases in the environment, is the end result of this little building. This gadget makes it simple for users to keep an eye on the quality of the air in their surroundings and offers a useful indicator for enhancing both indoor and outdoor air safety.
We took readings in two different locations in my city to test our setup: on my rooftop and close to a green area. The low carbon concentration in the green area contrasts with the high carbon concentration in the city, which is why we got different readings.
The city's readings ranged from 550 to 620, depending on whether the area was close to a major road, an industrial region, or a green space with lots of trees and few cars.
If we take the tests in places where gases are less common, such mountains or hills, the values may drop much further.
Overall, this setup was finished, but I would like to make revisions to this project in the future to further reduce its size and make it extremely portable.
In addition, we appreciate PCBWAY's support of this project. Visit them for a variety of PCB-related services, such as stencil and PCB assembly services, as well as 3D printing services.
Thanks for reaching this far, and I will be back with a new project pretty soon.
Peace.
#include <Wire.h>
#include <Adafruit_GFX.h>
#include <Adafruit_SSD1306.h>
#define SCREEN_WIDTH 128
#define SCREEN_HEIGHT 64
#define OLED_RESET -1
Adafruit_SSD1306 display(SCREEN_WIDTH, SCREEN_HEIGHT, &Wire, OLED_RESET);
const int analogPin = 35; // A3
const int digitalPin = 2; // D2
void setup() {
Serial.begin(9600);
pinMode(digitalPin, INPUT);
// SSD1306 OLED display initialization
if (!display.begin(SSD1306_SWITCHCAPVCC, 0x3C)) {
Serial.println(F("SSD1306 allocation failed"));
for(;;);
}
display.display();
delay(2000); // Pause for 2 seconds
display.clearDisplay();
}
void loop() {
int analogValueRaw = analogRead(analogPin);
int analogValue = map(analogValueRaw, 0, 4095, 0, 1023); // Scale the value to match the Pico's range
int digitalValue = digitalRead(digitalPin);
String airQuality = getAirQuality(analogValue);
Serial.print("Analog Value (Raw): ");
Serial.print(analogValueRaw);
Serial.print(", Scaled Value: ");
Serial.print(analogValue);
Serial.print(", Digital Value: ");
Serial.println(digitalValue);
// Display scaled analog value and air quality condition on OLED
display.clearDisplay();
display.setTextSize(2); // Normal 1:1 pixel scale
display.setTextColor(SSD1306_WHITE); // Draw white text
display.setCursor(0, 10); // Start at top-left corner
display.print("Value: ");
display.println(analogValue);
display.setTextSize(1);
display.setCursor(0, 40);
display.print("Air Quality: ");
display.println(airQuality);
display.display();
delay(1000);
}
String getAirQuality(int analogValue) {
if (analogValue <= 200) {
return "Excellent";
} else if (analogValue <= 400) {
return "Good";
} else if (analogValue <= 600) {
return "Moderate";
} else if (analogValue <= 800) {
return "Poor";
} else {
return "Very Poor";
}
}
Portable Air Quality Meter
- Comments(1)
- Likes(0)
- 0 USER VOTES
- YOUR VOTE 0.00 0.00
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
More by Arnov Arnov sharma
- 64x32 Matrix Panel Setup with PICO 2 Greetings everyone and welcome back.So here's something fun and useful: a Raspberry Pi Pico 2-powere...
- Portable Air Quality Meter Hello everyone, and welcome back! Today, I have something incredibly useful for you—a Portable Air Q...
- WALKPi PCB Version Greetings everyone and welcome back, This is the WalkPi, a homebrew audio player that plays music fr...
- Delete Button XL Greetings everyone and welcome back, and here's something fun and useful.In essence, the Delete Butt...
- Arduino Retro Game Controller Greetings everyone and welcome back. Here's something fun.The Arduino Retro Game Controller was buil...
- Super Power Buck Converter Greetings everyone and welcome back!Here's something powerful, The SUPER POWER BUCK CONVERTER BOARD ...
- Pocket Temp Meter Greetings and welcome back.So here's something portable and useful: the Pocket TEMP Meter project.As...
- Pico Powered DC Fan Driver Hello everyone and welcome back.So here's something cool: a 5V to 12V DC motor driver based around a...
- Mini Solar Light Project with a Twist Greetings.This is the Cube Light, a Small and compact cube-shaped emergency solar light that boasts ...
- PALPi V5 Handheld Retro Game Console Hey, Guys what's up?So this is PALPi which is a Raspberry Pi Zero W Based Handheld Retro Game Consol...
- DIY Thermometer with TTGO T Display and DS18B20 Greetings.So this is the DIY Thermometer made entirely from scratch using a TTGO T display board and...
- Motion Trigger Circuit with and without Microcontroller GreetingsHere's a tutorial on how to use an HC-SR505 PIR Module with and without a microcontroller t...
- Motor Driver Board Atmega328PU and HC01 Hey, what's up folks here's something super cool and useful if you're making a basic Robot Setup, A ...
- Power Block Hey Everyone what's up!So this is Power block, a DIY UPS that can be used to power a bunch of 5V Ope...
- Goku PCB Badge V2 Hey everyone what's up!So here's something SUPER cool, A PCB Board themed after Goku from Dragon Bal...
- RGB Mixinator V2 Hey Everyone how you doin!So here's a fun little project that utilizes an Arduino Nano, THE MIXINATO...
- Gengar PCB Art Hey guys and how you doing!So this is the GENGAR PCB Badge or a Blinky Board which is based around 5...
- R2D2 Mini Edition So here's something special, A Mini R2D2 PCB that speaks ASTROMECH.Astromech is a fictional language...
-
Atomic Force Microscope - electronic part
46 0 0 -
-
-
DIY Fiber Laser Tube Cutting Machine
118 0 1 -
-
-
DIY Transistor Tester | Build Your Own LCR Meter at Home with Arduino Nano
278 0 3 -