Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to use raspberry pie to determine particulate matter

2025-03-29 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/01 Report--

This article mainly introduces how to use raspberry pie to determine particulate matter, which has a certain reference value. Interested friends can refer to it. I hope you can learn a lot after reading this article.

What is particulate matter?

Particles are tiny particles in dust or air. The difference between PM10 and PM2.5 is that PM10 refers to particles with a particle size less than 10 microns, while PM2.5 refers to particles with a particle size less than 2.5 microns. When the particle size is less than 2.5 microns, because they can be inhaled into the alveoli and affect the respiratory system, the smaller the particles, the greater the harm to human health.

The World Health Organization recommends that the concentration of particulate matter is:

The average annual PM10 is no more than 20 μ g.

The average annual PM2.5 is no higher than 10 μ g

When exceeding the standard, the average daily PM10 is not higher than 50 μ g.

When exceeding the standard, the average daily PM2.5 is no more than 25 μ g.

The above values are actually lower than the standards of most countries, for example, the annual average allowed by the European Union for PM10 is no more than 40 μ g.

What is the Air quality Index Air Quality Index (AQI)?

The air quality index is based on the measured value of particulate matter to evaluate the air quality. however, due to the different calculation methods among countries, there is no unified standard for this index. The Wikipedia entry on the air quality index gives an overview of this. Our school is based on the classification established by Environment Protection Agency (EPA) of the American Environmental Protection Association.

Air quality index

What preparations are required for the determination of particulate matter?

The determination of particulate matter only requires the following two kinds of equipment:

Raspberry pie (unlimited in style, * with WiFi)

SDS011 particle sensor

Particulate matter sensor

If it is a raspberry pie Zero W with only Micro USB, you also need an adapter cable connected to the standard USB port, which costs only $20, while the sensor comes with a USB adapter adapted to the serial interface.

Installation process

For raspberry pie, just download the corresponding Raspbian Lite image and write it to your Micro SD card (there are many tutorials online on how to set up a WLAN connection, so I won't go into details).

If you want to use SSH, you also need to create an empty file called ssh in the boot partition. The IP of the raspberry pie is obtained through the router or DHCP server, and then you can log in to the raspberry pie via SSH (the default password is raspberry):

$ssh pi@192.168.1.5

First, we need to install these packages on the raspberry pie:

$sudo apt install git-core python-serial python-enum lighttpd

Before we begin, we can use dmesg to obtain the serial interface to which the USB adapter is connected:

$dmesg [5.559802] usbcore: registered new interface driver usbserial [5.559930] usbcore: registered new interface driver usbserial_generic [5.560049] usbserial: USB Serial support registered for generic [5.569938] usbcore: registered new interface driver ch441 [5.570079] usbserial: USB Serial support registered for ch441-uart [5.570217] ch441 1.4Mor 1.0: ch441-uart converter detected [5.575686] usb 1For 1.4: ch441-uart converter now attached to ttyUSB0

On the * * line, you can see the interface ttyUSB0. Then we need to write a Python script to read the sensor's data and store it in JSON format, which can be displayed through a HTML page.

Read data on raspberry pie

First create a sensor instance, read the sensor data every 5 minutes for 30 seconds, and these values can be adjusted later. At the interval of every two measurements, we set the sensor to sleep mode to extend its service life (the manufacturer thinks the life of the component is about 8000 hours).

We can download the Python script using the following command:

$wget-O / home/pi/aqi.py https://raw.githubusercontent.com/zefanja/aqi/master/python/aqi.py

You also need to execute the following two commands to ensure that the script runs properly:

$sudo chown pi:pi / var/www/html/$ echo'[]'> / var/www/html/aqi.json

The following script can be executed:

$chmod + x aqi.p$. / aqi.pyPM2.5:55.3, PM10:47.5PM2.5:55.5, PM10:47.7PM2.5:55.7, PM10:47.8PM2.5:53.9, PM10:47.6PM2.5:53.6, PM10:47.4PM2.5:54.2, PM10:47.3... Automate script execution

Just using a service such as crontab, we don't need to start the script manually every time. Follow the following command to open the crontab file:

$crontab-e

Add this line at the end of the file:

@ reboot cd / home/pi/ & &. / aqi.py

Now our script will be executed automatically every time the raspberry pie is restarted.

HTML page showing measured values of particulate matter and air quality index

We have installed a lightweight web server lighttpd earlier, so we need to place the HTML, JavaScript, and CSS files in the / var/www/html directory so that the data can be accessed from computers and smartphones. Execute the following three commands to download the corresponding file:

$wget-O / var/www/html/index.html https://raw.githubusercontent.com/zefanja/aqi/master/html/index.html$ wget-O / var/www/html/aqi.js https://raw.githubusercontent.com/zefanja/aqi/master/html/aqi.js$ wget-O / var/www/html/style.css https://raw.githubusercontent.com/zefanja/aqi/master/html/style.css

In the JavaScript file, the process of opening the JSON file, extracting data and calculating the air quality index is realized, and then the background color of the page will change according to the division standard of EPA.

You only need to visit the address of raspberry pie with your browser to see data such as the current particulate matter concentration: http://192.168.1.5:

This page is simple and extensible, such as adding a table showing historical data over the past few hours, and so on.

Thank you for reading this article carefully. I hope the article "how to use raspberry pie to determine particulate matter" shared by the editor will be helpful to everyone. At the same time, I also hope that you will support and pay attention to the industry information channel. More related knowledge is waiting for you to learn!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report