Software apps and online services
If you have wanted to make an air quality monitor, or wanted to experiment with air quality sensors, or even just was curious to the wide variety of sensors available to interface with an Arduino, then this project should suit you very much. It mainly involves a dust sensor as an input feeding into an Arduino compatible board. This particular sensor runs on multiple components inside an enclosure, such as: an Infrared LED, a set of lens, a photodiode detector and electromagnetic shielding. All those parts work together to read the air quality by measuring the dust concentration. The Particulate Matter level (PM level) in the atmosphere is measured by counting the Low Pulse Occupancy time (LPO time) in a given time unit in which the LPO time is proportional to the PM concentration. So, this sensor can provide reliable data for air purifier systems where it is responsive to a PM level of a diameter to less than 1μm. For this project, the parts you will need include:
- 1 Grove - Dust Sensor (PPD42NS)
- 1 Arduino (the Seeeduino v4.2 is used in this example)
- 3 Jumper Wires (Male to Male)
- 1 USB Data Cable (depends on the Arduino)
Please visit this link here for NextPCB's special offers.
This project's circuit is so simple that you won't even need a breadboard at all. The input dust sensor connects directly to the Arduino microcontroller with three jumper wires. As a precaution before starting, remove any electrical power source through your Arduino. Then, connect the yellow wire (signal) on the dust sensor to D8 (digital pin 8) on your Arduino board through the JST connector. After, connect the red wire (VCC/+) of the sensor's JST connector to the 5v (+5 volts) which is located on your Arduino power pins row. Lastly, connect the black wire (GND/-) from your Grove Dust Sensor, again, through the JST, to one of your Arduino's GND (-) pins. That is it for the hardware setup regarding this project!About the code
This code consists of multiple functions which is really helpful in Arduino, especially when dealing with complex sensors and interfaces. This code starts off with declaring a pin for this sensor, which is D8 (digital pin 8) as an integer. For the next two lines, we declare extended size variables for number storage only. It can be used later to assign values or readings to that variable. We can write and store data in unsigned long variables such as data coming out from sensors, math calculations, readings over time, etc.. The variables in those two lines are: duration and starttime. Moving on, there are additionally two more unsigned long variables with a reading currently assigned (sampletime_ms and lowpulseoccupancy), it will be used further down the code. The benefit with these variables are that they can carry more data as they have extensive size, proving to be useful in gathering data. The following float variables (ratio and concentration) are for decimal numbers so with a pre-set value declared, it could be used to read decimal numbers later in this sketch. Now, we move onto the void setup section, beginning with setting up the serial communication to output data from the sensor at a rate of 9600 bauds. Followed by the next line, we set D8 (digital pin 8) as an input pin, so that data from the sensor will be sent to the Arduino microcontroller. After, we command the variable, starttime, to read the current time in milliseconds, so that the variable can be involved with timing, further down the lines. That is it for the setup section, and now, it is time to get into the void loop part. The first line of the void loop is one of the Advanced I/O functions where it reads the pulse, whether it is HIGH or LOW (1 or 0). In this code, the pulseIn function is set LOW, so this function will start timing the LOW pulse until it changes to HIGH. Following that function, the time collected will be assigned to the unsigned long variable of duration, reading the time in microseconds. Now, we declare the variable of lowpulseoccupancy to read its own reading itself, plus the readings of the variable duration. We have now come to the major part of the code, where we calculate and transform raw data into what we can read, units. The if statement says, that if the variable starttime, subtracted by the current, counting time, is greater than or equal to the value of the variable sampletime_ms (2000 milliseconds), it's programmed to do the rest of the code below that if statement. Subsequently, we make use of one of our past declared variables by using the variable ratio to assign it to a value, which is lowpulseoccupancy, which we came across, and, with a little bit of math, we can make a new reading assigned to that variable of ratio. So, variable ratio equals, lowpulseoccupancy(which was added to the readings of the variable duration), divided by variable sampletime_ms multiplied by 10, to get the integer percentage. Succeeding that, we convert our values we have calculated into a unit of pcs/0.01cf. Our variable we'll be using for this will be named concentration. Starting off, concentration consists of 1.1 multiplied by the value of the variable ratio to the power of 3. Then, that continuous equation is subtracted by 3.8, times the variable ratio to the power of 2. Further on, it is added by 520, multiplied by the variable ratio again, and finally, that consecutive reading is added on to 0.62. The pow() function, in the sketch, is used to raise an integer, value or a variable to the power of something else. As we end this code, we print the readings into the serial monitor, with the phrase "Concentration =" on the serial monitor before we print the variable concentration, because that variable converted the raw data from the sensor into a suitable unit of measurement. Further more, on the same line on the serial monitor, we print the units of that value (pcs/0.01cf) to completely end the readings. So, the final readings on the serial monitor will read "Concentration = (reading) pcs/0.01cf". Lastly, the variable lowpulseoccupancy is reseted to 0 for a new reading to be gained as per the void loop, as well as the variable starttime (current time). Finally, those lines wrap up our code, it is short in length, but complicated when it's stripped apart.Amazing opportunities
It is a trustworthy website for ordering electronic components with cheap price and excellent quality.
Also, be sure to check out PCBWay, a leading manufacturer and distributor in PCB design and manufacturing. They have amazing prices and excellent quality in their services, so don't miss out on them! Plus, PCBWay has an amazing website, online Gerber viewer function and a gift shop so make sure to check out their links below:
PCBWay Free Online Gerber Viewer Function: https://www.pcbway.com/project/OnlineGerberViewer.html
PCBWay Gift Shop: https://www.pcbway.com/project/gifts.html
Make sure you check out the review for this meter by clicking here.Enjoy! Contact us for any inquiries!