Tutorial 10 - How to enable the air quality monitoring with PM2.5 sensor It describes about how to use PM2.5 sensor for monitoring air quality on I-Pi Hardware Requirement: I-Pi SMARC PX30 Development Kit Monitor, Keyboard and Mouse HDMI Display Refer this link for I-Pi Connectionshttps://www.youtube.com/watch?v=luzU_IYuRQI Software Requirement Debian/Ubuntu/Yocto as desired OS. Here is the images for you: The download link for the latest Debian binary images which built by ADLINK if you need. The download link for the latest Ubuntu binary images which built by ADLINK if you need. The download link for the latest Yocto binary images which built by ADLINK if you need. Refer this links flashing the Image in to micro SD card https://www.youtube.com/watch?v=-Vq7yLV5thQ&t=11s ( Guide to How to Flash Yocto SD Card image) https://www.youtube.com/watch?v=qunkNOpYzGQ&t=72s ( Guide to how to Flash Debian/Ubuntu SD Card image) PM2.5 sensor descriptionPM2.5 laser dust sensor is a digital universal particle concentration sensor, it can be used to obtain the number of suspended particulate matter in a unit volume of air within 0.3 to 10 microns. The Air Quality sensors can be embedded in a variety of concentrations of environment-related instruments suspended particulate matter in the air, to provide timely and accurate concentration data. How it worksThis PM2.5 sensor uses a laser scattering theory. And the scattering of laser irradiation in the air suspended particles, while collecting the scattered light at a specific angle, to obtain the scattering intensity versus with time curve. After the microprocessor data collection, it gets the relationship between the time domain and frequency domain by Fourier transform, and then through a series of complex algorithms to obtain the number of particles in the equivalent particle size and volume units of different size. Specifications Operating voltage: 4.95 ~ 5.05V Maximum electric current: 120mA Measuring pm diameter: 0.3-1.0, 1.0-2.5, 2.5-10(um) Measuring pm range: 0~500 ug/m3 Standby current: ≤200 uA Response time: ≤10 s Operating temperature range: -20 ~ 50C Operating humidity range: 0 ~ 99% RH Maximum size: 65 × 42 × 23 (mm) MTBF: >= 5 years Quick response Standard serial input word output Second-order multi-point calibration curve The minimum size of 0.3 micron resolution Step 1: Updating RepositoriesInsert the SD card and start the development host. Its always better to update your apt repositories in your host machine $ sudo apt update Step 2: Location of directoryif you boot your I-Pi with Yocto, go to the following directory $ cd /usr/share/upm/examples/python/ If you boot your I-Pi with Debian/Ubuntu, go to the following directory $ cd /usr/local/share/upm/examples/python/ Step 3: Sensor codeThen you can find the souce code in this directory named as hka5.pyTo view the code, type $ sudo vi hka5.py You can also change the time in loop as per your requirement from __future__ import print_functionimport time, sys, signal, atexitfrom upm import pyupm_hka5 as sensorObjdef main():# Instantiate a HKA5 sensor on uart 0. We don't use the set or# reset pins, so we pass -1 for them.sensor = sensorObj.HKA5(0, -1, -1)## Exit handlers ### This function stops python from printing a stacktrace when you hit control-Cdef SIGINTHandler(signum, frame): raise SystemExit# This function lets you run code on exitdef exitHandler(): print("Exiting") sys.exit(0)# Register exit handlersatexit.register(exitHandler)signal.signal(signal.SIGINT, SIGINTHandler)# update once every 2 seconds and output datawhile (True): sensor.update() print("PM 1 :", end=' ') print(sensor.getPM1(), end=' ') print(" ug/m3") print("PM 2.5:", end=' ') print(sensor.getPM2_5(), end=' ') print(" ug/m3") print("PM 10 :", end=' ') print(sensor.getPM10(), end=' ') print(" ug/m3") print() time.sleep(2)if __name__ == '__main__':main() Step 4: Executionexecution the code $ sudo python3 hka5.py If you are not the root user, add sudo before the executing commands. The output of PM2.5 sensor changes according to changes in the atmospheric air to indicate the PM levels. The below table shows the index values and their categories