Introduction: Make One PM2.5/air Quality Monitor With Arduino UNO

Picture of Make One PM2.5/air Quality Monitor With Arduino UNO

Make one PM2.5 monitor with Arduino UNO

use Arduino unoR3 board and one arduino compatible 4-digital tube to collect and display the PM2.5 value.

one laser PM2.5 sensor SDS011(www.inovafitness.com) is used for the PM2.5 detect.

Step 1: Download Arduino IDE

Picture of Download Arduino IDE

Arduino IDE: the version of 1.0.6 is used. goto http:// www. arduino. cc to download.

Step 2: Hardware Connect:

Picture of Hardware Connect:

SDS011----this sensor has 7 pins. 3&5 are the power pins, and 6&7 are the ttl-5V com port pins.

1----NC

2----NC

3----5V

4----NC

5----GND

6----arduino-tx

7---- arduino-rx

4-digital tube connect:

1— ser--connect-to----arduino8

2— clk—connect-to----arduino9

3— st—connect-to----arduino10

4— gnd—connect-to----gnd

5— vcc—5V--connect-to----5V

Step 3: Open and Upload the Firmware

Picture of Open and Upload the Firmware

open the "ArduinoSDS011Demo.ino" file, and upload. the file would be automatically compiled and uploaded to arduino board.

code explain:

function Setup:the display and com init.

function Loop: function ProcessSerialData read the PM2.5 data,function Display display the data.

Step 4: DONE

Picture of DONE

the PM2.5 value is about 80 without smoke. It reach up to 999 within 5 seconds when the smoke is generated.

That's all.

Comments

pjozsi (author)2017-08-16

Please help me! Max7219 LED display does not work. No light. What should I change my code? Display wiring is OK, working with another program.

Thank you very much

selinaguo (author)2017-02-13

Hi! That's a wonderful project. I'm still a student and have no programming experience. I'm also curious about whether it is possible to further program the chip so that the detected value of PM can control a motor. For example, the motor can be turned on only if the detected value exceeds a certain standard. Thanks a lot!

Va_Tech_EE (author)2016-08-13

Sorry to say, but I believe there is a bug in your code!

If you look in the sensor datasheet, you do not construct an int out of the low and high bytes of PM10 and PM2.5 like in the code you posted. The datasheet says to do this instead:

PM2.5 value: PM2.5 (μg /m3) = ((PM2.5 High byte *256) + PM2.5 low byte)/10

PM10 value: PM10 (μg /m3) = ((PM10 High byte *256) + PM10 low byte)/10

datasheet link: http://inovafitness.com/software/SDS011%20laser%20PM2.5%20sensor%20specification-V1.3.pdf

the datasheet says value is calculated in 2 steps:
1 tmp=high*256+low;
2 value=tmp/10;
for the first step, tmp=high*256+low. is exactly the same as tmp=(high<<8)+low;

for the second step, you are right, I have not done the second step in ProcessSerialData function.
This is because I do not know how anduino deal with floating point number.
But I have done the second step in display function. so the display should be right.

Thank you for your attention, and your comment.

Ahh, I see. Arduino handles floats like any other C++ microcontroller. When you divide by 10, just write it as 10.0 and make sure the variable the value is being stored in is type "float"

iot_lab (author)2016-06-22

Hi,
I'm trying to make it but having trouble reading the PM values. The connections:

SDS011 --- Arduino Uno

TX RX

RX TX

GND GND

5V 5V

I don't have LCD so I comment the line //Display(); and replace it by 2 LEDs (they will be on if the value is 0)

I always receive 0 for both PM 10 & PM 2.5.
Do you have any hint what can go wrong?

arumpsp (author)2016-01-17

Hi, thanks for making this! I am a newbie and recently looked for SDS011 tutorials but couldn't find much. Btw I planned to use a 1602 LCD instead of the 4-digital tube for display, could you tell which part of the code should be changed?

jiangshan00000 (author)arumpsp2016-01-17

their are one function you should change.
Display();
the function do 3 things:
1 clear the display buffer;
2 DisPm25data function for pm2.5 display;
3 DisPm10data function for pm10 display;

arumpsp (author)jiangshan000002016-04-26

I made it! Thanks for sharing!

James-P (author)2016-03-10

I have managed to have an SDS011 working well with an Arduino Mega, but the sensor has now failed. I think this may be because sensor uses 3.3V serial whereas the Mega runs its at 5V. However you suggest that the TTL level for the SDS011 is 5v. Can you confirm please.SDS011

jiangshan00000 (author)James-P2016-03-10

could you do a specific description of your 'failed'?

SDS011 should compatible with both 5V & 3.3V ttl voltage.

the working voltage is about 3v-5.3v.

you could insert a resistor of about 10K to pull-up to 5V to the arduino 5v rx port.

James-P (author)jiangshan000002016-03-11

Thank you for the quick reply; it is useful. I mean failed by the fan not running and no output on the SDS011 despite 5V being confirmed on the supply. I don't know the reason for failure; I thought mismatch of TTL level might be why as a TTL level of 3.3V is quoted in the the later (current) version of the SDS011 spec.

BrandonZ2 (author)2016-02-01

Could you post a link of the display that you bought?

biswajit11 (author)2016-01-24

7-segment display used is 4-digit or 8 digit. Please share the link and part number to purchase the display

theghostlibrary (author)2016-01-15

Thanks for this! I too have found that there are some problems with serial data conflicts if as I am you are using the serial monitor instead of an lcd display.

Question about the sensor and values - if the variable pm25 is 994, does that mean the pm2.5 level is actually 99.4? i.e. /10?

Also, what is the part number for the lcd display you used? did you buy it on taobao?

Thanks!

1 yes, 994 means 99.4ug/m3;

2 yes, search "德飞莱 595" in taobao, you would find it;

jm82792 (author)2015-08-30

Dear sir,

I have been using your code, and it works well.
However, it appears the serial communications part doesn't play nicely with other codes, and people on the Arduino forum say it needs some changes.
Would you consider fixing it up some so it places nicely with other libraries, and having me pay you money for your time with the end result being open source?
I lack the programming experience, and the capacity to do it on my own.
Regardless I appreciate your efforts, and the monitoring of the volcanic pollution here has been rather interesting to say the least.

Thanks again!

Sincerely
Joshua Martin Paauilo, Hawai'i

jiangshan00000 (author)jm827922015-09-08

Hi jm, If you could give me a more specific question, I may help you more quickly.
for example, could you give me a project that the pm2.5 parse code could not work?

KanagarajS (author)2015-08-01

Hi

Kindly suggest how to measure PM10 in the above project

their are two vars in the above code: Pm25 and Pm10, where the var Pm10 is probabily what you want?

benjamyn.lyall (author)2015-03-19

Thank you so much for all your help, hear are more pictures of my LED

if you have not solve the problem, just leave an email so that i could send you a demo code

i cant seem to get onto the website you have put the code on

Thanks

Ben

connect:

Arduino Max7219 LED

8 --DIN

9 --CLK

10 --CS

LED GND & VCC connect to one 5V power.

test code:

hi thsnks again for all your help.

i cant seem to get onto the website you have put the code on

Thanks

Ben

benjamyn.lyall (author)2015-03-18

Hi i was wondering if you could help me again.

On my LED display i have 2 sets of 5 pins seen in picture 1 and 2 bellow and i have 6 pins on my sensor which are shown in picture 3 bellow. Could you tell me what i need to plug into where on my arduino uno ??

Thankyou very much

Ben

BTW: maybe you could take a clear photo of your LED which chip mark, so that I could tell you how to drive your LED.

my LED display :

================================

the display is using two 74hc595 chips, below is how the chip works.

The magic of the display trick is in functions:SendByte, Send2Byte and Out595.

3 ports are used latch(arduino 9), sclk(arduino 9) and ser(arduino 10).

function SendByte:

ser is the serial data in port. sclk is the data clock. the data is collected on the rising edge of the sclk.

function Send2Byte: just send byte one by one.

function Out595: their is one port called RCK(latch port), when this port is rising edge, the display be refreshed to the new 2 bytes.

================================================

I could not see your led driver chip, so I could say no more.

benjamyn.lyall (author)2015-03-06

This looks really good im looking forward to having a go for my self as part of a university project im doing on Air pollution. One thing im haveing problems with however is finding a cheap "laser PM2.5 sensor SDS011".

Any help or advice ??

you could contact www.inovafitness.com, for a better price.

BTW: It's less than 40$ if you have quantity.

jimjutte (author)2015-03-04

This looks incredibly cool and relevant... I live just west of Shanghai where I work as a science teacher. With such a simple set up, it looks like a great science project for the kids. Thanks for posting. Now all I have to do is figure out where these boards are in China ;)

Cheers

PS. If anyone needs to know, there is an AQI to concentration calculator on the "Airnow" website. That was something that I was initially concerned about as well.

http://www.airnow.gov/index.cfm?action=resources.aqi_conc_calc

mzeiger (author)2015-02-12

What units is your sensor using? I like the idea as I work in the air emissions industry, but this would be useless to me without giving some sort of units and a way to calibrate it.

jiangshan00000 (author)mzeiger2015-02-13

The unit is ug/m^3

BTW: the sensor is the ttl serial-port interface, it's easy to get the data and do something else. I just get the data and display. you could modify the data as you like.

tomatoskins (author)2015-02-12

This is really interesting! We have horrible air here in Utah and something like this would be very interesting to have hanging around. Thanks!