Air pollution is a major problem in many cities, with air quality indexes getting worse every day. According to the World Health Organization, more people die prematurely due to the impact of harmful particles present in the air than die in car accidents. According to the Environmental Protection Agency (EPA), indoor air can be 2 to 5 times more toxic than outdoor air. So here we built a device to monitor air quality by measuring PM2.5 and PM10 particles in the air.
We previously used the MQ135 gas sensor for air quality monitoring and the Sharp GP2Y1014AU0F sensor to measure the dust density in the air. This time we are using SDS011 sensor with Arduino Nano to build an air quality analyzer. The SDS011 sensor can calculate the concentration of PM2.5 and PM10 particles in the air. Here, real-time PM2.5 and PM 10 values will be displayed on the OLED display.
Required components
Arduino Nano
Nova PM sensor SDS011
0.96' SPI OLED display module
jumper
Nova PM sensor SDS011
The SDS011 sensor is the latest air quality sensor developed by Nova Fitness. It works on the principle of laser scattering and can obtain the particle concentration of 0.3 to 10 μm in the air. The sensor consists of a small fan, air inlet valve, laser diode and photodiode. Air enters through the air inlet, a light source (laser) illuminates the particles, and the scattered light is converted into a signal by a photodetector. These signals are then amplified to obtain the particle concentrations of PM2.5 and PM10.
SDS011 sensor specifications:
Output: PM2.5, PM10
Measuring range: 0.0-999.9μg/m3
Input voltage: 4.7V to 5.3V
Maximum current: 100mA
Sleep current: 2mA
Response time: 1 second
Serial data output frequency: 1 time/second
Particle size resolution: ≤0.3μm
Relative error: 10%
Temperature range: -20~50°C
0.96' OLED display module
OLED (organic light-emitting diode) is a self-luminous technology built by placing a series of organic films between two conductors. When an electric current is applied to these films, bright light is produced. OLED uses the same technology as TVs, but has fewer pixels than most of our TVs.
For this project, we are using a monochrome 7-pin SSD1306 0.96” OLED display. It can work on three different communication protocols: SPI 3-wire mode, SPI 4-wire mode and I2C mode. The following table explains the pins and their functions Explained:
Learn more about OLEDs and their interfaces with different microcontrollers via the links below.
Air quality analyzer circuit diagram
The circuit diagram for measuring PM2.5 and PM10 particles using Arduino is very simple and is shown below.
Both the SDS011 sensor and the OLED display module are powered by +5V and GND. The transmitter and receiver pins of SDS011 are connected to the D3 and D4 pins of the Arduino Nano. Since the OLED Display module uses SPI communication, we established SPI communication between the OLED module and Arduino Nano. The connections are shown in the table below:
Build the circuit on the performance board
I also soldered all the components on the performance board to give it a neat look. But you can also make them on a breadboard. The board I made is as follows. When soldering, make sure not to sort the wires. The performance board I welded is shown below:
Air quality monitor code description
The complete code for this project is given at the end of the document. Here we will explain some important parts of the code.
This code uses the SDS011, Adafruit_GFX and Adafruit_SSD1306 libraries. These libraries can be downloaded from the library manager in the Arduino IDE and can be installed from there. To do this, open the Arduino IDE and go to Sketch » Include Library » Manage Libraries. Now search for SDS011 and install R. Zschiegner's SDS Sensor library.
Likewise, install Adafruit's Adafruit GFX and Adafruit SSD1306 libraries.
After installing the libraries into the Arduino IDE, start the code by including the required library files.
#include
#include
#include
#include
In the next few lines, define two variables to store PM10 and PM2.5 values.
float p10,p25;
Then, define the width and height of the OLED. In this project, we are using a 128×64 SPI OLED display. You can change the SCREEN_WIDTH and SCREEN_HEIGHT variables according to your display.
#define SCREEN_WIDTH 128
#define SCREEN_HEIGHT 64
Then define the SPI communication pins connected to the OLED display.
#define OLED_MOSI 9
#define OLED_CLK 10
#define OLED_DC 11
#define OLED_CS 12
#define OLED_RESET 13
Then, create an Adafruit display instance using the width and height defined earlier using the SPI communication protocol.
Adafruit_SSD1306 display (SCREEN_WIDTH, SCREEN_HEIGHT, OLED_MOSI, OLED_CLK, OLED_DC, OLED_RESET, OLED_CS);
Now in the setup() function, initialize the serial monitor with a baud rate of 9600 for debugging. In addition, use the begin() function to initialize the OLED display and SDS011 sensor.
my_sds.begin(3,4);
SerialNumber.Start(9600);
display.begin(SSD1306_SWITCHCAPVCC);
In void loop(), read PM10 and PM2.5 values from SDS011 sensor and print the readings on the serial monitor.
void loop(){
Error = my_sds.read(&p25,&p10);
if(!error){
Serial.println("P2.5:"+String(p25));
Serial.println("P10:"+String(p10));
After that, use setTextSize() and setTextColor() to set the text size and text color.
display.setTextSize(2);
display.setTextColor(white);
Then in the next line, use the setCursor(x,y) method to define the position of the starting text. Here we will display PM2.5 and PM10 values on the OLED display, so the first row starts from (0,15) and the second row starts from (0, 40) coordinates.
display.setCursor(0,15);
display.println("PM2.5");
display.setCursor(67,15);
display.println(p25);
display.setCursor(0,40);
display.println("PM10");
display.setCursor(67,40);
display.println(p10);
Finally, call the display() method to display the text on the OLED Display.
display.display();
display.clearDisplay();
Arduino air quality monitor test
Once the hardware and code are ready, it's time to test the device. To do this, connect the Arduino to the laptop, select the board and port, and click the upload button. As shown in the picture below, it will display PM2.5 and PM10 values on the OLED display.
#include
#include
#include
#includefloating
p10,p25;
Internal error;
SDS011 my_sds;
#define SCREEN_WIDTH 128 // OLED display width, in pixels
#define SCREEN_HEIGHT 64 // OLED display height, in pixels
// Use Software SPI connected SSD1306 display declaration (default case):
#define OLED_MOSI 9
#define OLED_CLK 10
#define OLED_DC 11
#define OLED_CS 12
#define OLED_RESET 13
Adafruit_SSD1306 display (screen width, screen height,
OLED_MOSI, OLED_CLK, OLED_DC, OLED_RESET, OLED_CS);
Invalid settings () {
my_sds.begin(3,4);
Serial number. Begin (9600);
display.begin(SSD1306_SWITCHCAPVCC)
; display.clearDisplay()
; Display.Display();
}
Invalid loop () {
Error = my_sds.read(&p25,&p10);
if (! Error) {
Serial.println("P2.5:"+String(p25));
Serial.println("P10:"+String(p10));
display .setTextSize(2);
display.setTextColor (white);
display.setCursor(0,15);
display.println("PM2.5");
display.setCursor(67,15);
display.println(p25);
display .setCursor(0,40);
display.println("PM10");
display.setCursor(67,40);
display.println(p10)
; display.display();
display.clearDisplay();
}
Delay(100) ;
}
Previous article:Analyze the differences in EMI test methods and results of receivers and spectrum analyzers
Next article:Built a pulse oximeter using MAX30100 and ESP32
Recommended ReadingLatest update time:2024-11-16 09:28
- Keysight Technologies Helps Samsung Electronics Successfully Validate FiRa® 2.0 Safe Distance Measurement Test Case
- From probes to power supplies, Tektronix is leading the way in comprehensive innovation in power electronics testing
- Seizing the Opportunities in the Chinese Application Market: NI's Challenges and Answers
- Tektronix Launches Breakthrough Power Measurement Tools to Accelerate Innovation as Global Electrification Accelerates
- Not all oscilloscopes are created equal: Why ADCs and low noise floor matter
- Enable TekHSI high-speed interface function to accelerate the remote transmission of waveform data
- How to measure the quality of soft start thyristor
- How to use a multimeter to judge whether a soft starter is good or bad
- What are the advantages and disadvantages of non-contact temperature sensors?
- Innolux's intelligent steer-by-wire solution makes cars smarter and safer
- 8051 MCU - Parity Check
- How to efficiently balance the sensitivity of tactile sensing interfaces
- What should I do if the servo motor shakes? What causes the servo motor to shake quickly?
- 【Brushless Motor】Analysis of three-phase BLDC motor and sharing of two popular development boards
- Midea Industrial Technology's subsidiaries Clou Electronics and Hekang New Energy jointly appeared at the Munich Battery Energy Storage Exhibition and Solar Energy Exhibition
- Guoxin Sichen | Application of ferroelectric memory PB85RS2MC in power battery management, with a capacity of 2M
- Analysis of common faults of frequency converter
- In a head-on competition with Qualcomm, what kind of cockpit products has Intel come up with?
- Dalian Rongke's all-vanadium liquid flow battery energy storage equipment industrialization project has entered the sprint stage before production
- Allegro MicroSystems Introduces Advanced Magnetic and Inductive Position Sensing Solutions at Electronica 2024
- Car key in the left hand, liveness detection radar in the right hand, UWB is imperative for cars!
- After a decade of rapid development, domestic CIS has entered the market
- Aegis Dagger Battery + Thor EM-i Super Hybrid, Geely New Energy has thrown out two "king bombs"
- A brief discussion on functional safety - fault, error, and failure
- In the smart car 2.0 cycle, these core industry chains are facing major opportunities!
- The United States and Japan are developing new batteries. CATL faces challenges? How should China's new energy battery industry respond?
- Murata launches high-precision 6-axis inertial sensor for automobiles
- Ford patents pre-charge alarm to help save costs and respond to emergencies
- New real-time microcontroller system from Texas Instruments enables smarter processing in automotive and industrial applications
- Project Submission
- About crossover
- The download and win gift event is here again~you can learn and win prizes at the same time!
- Why is it said that the larger the ceramic capacitor package, the better the frequency characteristics?
- The smartwatch craze has left the survivors
- [TI recommended course] #Boost and buck-boost DCDC converters help wireless charging design#
- Milliohm meter based on [EVAL-ADICUP360] - Programming
- USB to TTL serial port debugging tool based on 2.4G wireless transmission
- When the epidemic in Shanghai is over, I plan to develop in other cities.
- [Technical Live Broadcast] Experts from MPS, Nexperia, and Tektronix gathered to discuss the key points of new energy vehicle power design