The article presents our experience in developing a solution for monitoring air quality in villages using a network of eco-sensors and providing information to users in real time based on Advantech technical solutions.
Smart cities and the problem of air pollution
More than 74% of Russia's population lives in large cities and urban population growth continues. High population density and production are accompanied by a deterioration in atmospheric air quality. The main sources are: industry, heat power and automobile transport. According to the World Health Organization, the most dangerous contaminant is fine dust, as it enters the lungs when breathing and is not excreted throughout the life.
According to the NAFI research in 2019, about
71% of citizens consider the environmental situation unsuccessful and attribute this to emissions from vehicles and industry. The problem is the timely identification of local sources of pollution.
One of the tasks of the National project “Digital Economy” for 2019-2024. is the transformation of priority sectors of the economy and the social sphere, including urban economy, through the introduction of digital technologies and platform solutions, mainly of domestic development. Within the framework of this project, on March 4, 2019, the Ministry of Construction and Housing and Communal Services approved the
Smart City standard, which contains a list of activities implemented as part of the digitalization of the urban economy.
The standard implies the implementation of solutions in cities with a population of more than 100 thousand people in 28 directions, among which the “Online Air Monitoring System” line is highlighted, which involves measures leading to an increase in environmental safety, ensuring control over the state of air quality, and administering city budget revenues in terms of environmental protection, increasing the level of attractiveness of the city for citizens.
In the framework of the national project “Ecology”, the
passport of which was approved by the decision of the Presidium of the Presidential Council for Strategic Development and National Projects on 12.24.2018, the federal project “
Clean Air ” is being implemented, aimed at improving the quality of atmospheric air in 12 industrial centers with a decrease the degree of air pollution to the level of “increased”, determined in accordance with the recommendations of
RD 52.04.667-2005 .
According to task 1.5 of this project, it is planned to integrate data from the modernized state observing network, territorial and local systems for monitoring air quality. This can make it possible to identify local sources of air pollution and control emissions based on air quality data obtained by a dense sensor network with high spatial resolution.
However, residents of small cities and towns are not involved in these large-scale federal projects and can only rely on their own resources. Despite the fact that the air quality in settlements remote from industrial centers is much higher, nevertheless, the problems of promptly identifying local sources of pollution are as acute as in densely populated areas.
Sensor Network for Air Quality Monitoring
The placement of eco-sensors at the infrastructure facilities of the village and in places of mass recreation allows you to ensure air quality control, improve environmental safety by informing residents, local governments and regulatory authorities. Using the
WISE-PaaS digital platform, it is possible to collect data from eco-sensors, analyze their variability and forecast the risks of air pollution. All this leads to an increase in the quality of life and attractiveness of the village for residents and guests.
The sensors themselves are, in fact, the connecting link between the real world and its digital counterpart, implemented using Advantech hardware. They measure the dust content in the air, its temperature, form message packets and send them wirelessly in the range of 868 MHz, in accordance with the LoRaWAN protocol, to the base station, where the data is packed into JSON text messages and then sent to the MQTT protocol to
WISE-PaaS digital platform, where it is already processed by the application server.
As a LoRa gateway, we use the
WISE-6610 device manufactured by Advantech's Czech branch. This is a fairly compact device mounted on a DIN rail or wall, with connectors for connecting an external antenna, LAN and power. Of the four contacts of the power connector, in fact, only two are used: red (+) and black (-). By default, the gateway operates in router mode and its LoRa module is turned off. To activate the device, you need to connect to it via an Ethernet cable and indicate in the browser address bar the address through which the gateway settings web interface is available:
http://192.168.1.1
At the authorization request, specify the default parameters (login: root, password: root) and get into the interface shown in the figure.
Here, the “User Modules” item is of most interest, through which you can configure the LoRa gateway and the local Node-RED server. We go into the settings of the LoRa gateway, where we can enable the LoRa module, specify the frequencies of the LoRa gateway radio channels, set the network server operation parameters and configure message transfer to the MQTT broker by specifying the host, port, username and password.
It remains only to bind the eco-sensors to the LoRa-gateway. To do this, we use the ABP (Activation-by-personalization) method. We go to the network server settings panel:
https://192.168.1.1:8443
select “Devices-Activated (Nodes)”, click on the “+ Create” button and in the window that appears specify three parameters: NwkSKey (network key), AppSKey (application key), DevAddr (sensor address). We indicate the same parameters in the settings of the eco-sensor.
To connect the
WISE-6610 to a local network, it must be put into DHCP client mode. After that, the device will itself detect the DHCP server on the local network to obtain an IP address and connect to the Internet. This is done through the main web interface: select the “Configuration-LAN” menu item and indicate “enabled” in the “DHCP Client” field.
WISE-PaaS Digital Platform
At the beginning of this year, more than 150 digital platforms for the Internet of things are known. Each of them has its own characteristics, advantages and disadvantages. Using the
WISE-PaaS platform allows you to solve the problem of collecting sensor network data and visualizing them.
Processing data from sensors on the digital platform
WISE-PaaS is carried out in several stages:
- receiving JSON messages from the LoRa gateway by the MQTT broker and forwarding them to the application;
- Reception of JSON-messages by Python-script, data processing and writing to the database;
- recording, storing and providing data using PostgreSQL DBMS;
- data visualization using WISE-PaaS / Dashboard ;
When creating a new virtual space on WISE-PaaS, the MQTT broker RabbitMQ is launched by default and is visible in the list of available services. Broker parameters (host, port, username, password) can be obtained through the web interface.
To create an application that receives measurement data from an MQTT broker and writes them to the database, you can use step-by-step instructions based on an example prepared by Advantech.
Create a working directory:
mkdir ~/wisepaas/
Go to it:
cd ~/wisepaas/
We are cloning an example with Github to retrieve MQTT data and write data to a PostgreSQL database:
git clone https://github.com/WISE-PaaS/example-py-iothub-postgresql.git
Preparing the index.py executable application consists in changing the values ​​of several parameters to the actual values ​​specified in the WISE-PaaS Control Panel.
… # MQTT(rabbitmq) service_name = 'p-rabbitmq-innoworks' … # Postgresql service_name = 'postgresql-innoworks' … schema = 'projectname' table = 'tablename' group = 'groupname' … def on_connect(client, userdata, flags, rc): client.subscribe("#") …
The
manifest.yml file contains application parameters: name, size of available RAM, disk quota, application launch command, list of used services.
--- applications: - name: py-postgresql-meteolab memory: 256MB disk_quota: 256MB buildpack: python_buildpack command: python index.py services: - rabbitmq
Connecting user
user with password
password to the
api.wise-paas.io server using the CloudFoundry client:
cf login -a api.wise-paas.io -u user@advantech.com -p password
Verify client connectivity to CloudFoundry:
cf target
Copying the application to the server without starting:
cf push py-postgresql-meteolab --no-start
Binding the application to the database with the group:
cf bs py-postgresql-meteolab postgresql -c '{\"group\":\"groupname\"}'
Binding an application to an MQTT broker:
cf bs py-postgresql-meteolab rabbitmq
Running the application on the server:
cf start py-postgresql-meteolab
Application operation control is carried out by checking the application execution log:
cf logs py-postgresql-meteolab --recent
It’s convenient to copy all application environment variables to a local JSON file:
cf env py-postgresql-meteolab > env.json
The PostgreSQL server is also started by default when creating virtual space. Since WISE-PaaS does not have a web interface for managing databases, it is therefore necessary to install some kind of client, for example, pgAdmin. Then, database tables are created and the process of recording data from sensors using the web interface is controlled.
Information Visualization Tools
The
WISE-PaaS digital platform includes
WISE-PaaS / Dashboard , which allows you to create graphic panels containing an arbitrary number of blocks with various display options. It can be text, graphs, charts, maps and much more.
Blocks are configured through the “Edit” menu. The source of the displayed data is an SQL query to the database. In addition, there are various configurable options for adjusting the display in the “Edit” menu.
For finer tuning, you can use “panel JSON”, which allows you to edit the settings in JSON format. This is sometimes necessary, since all parameters cannot be edited through the “Edit” panel.
Each panel has common settings. Here you can set the panel name, description, assign tags, make time settings, change the background.
In addition, WISE-PaaS / Dashboard has common settings for all panels. Here you can add a data source, manage groups and users, manage plugins (add, activate, delete), upload images and much more.
Conclusion
The use of an air quality monitoring system in a cottage village allows you to quickly identify sources of pollution, plan street cleaning and, ultimately, improve the quality of life of people. Integration of this system with video surveillance systems, access control and management, street lighting allows you to create “smart” digital solutions that increase the efficiency of operation of the cottage village.
This article was prepared by a team (V.V. Chukin, T.A. Lipatov, A.Yu. Ermakov) from
MeteoLab based on the results of the competition in the
Advantech AIoT Developer InnoWorks 2019 contest . The authors of the article are always happy to answer questions and consider proposals through the
feedback form , as well as apply the experience gained with the
Advantech WISE-PaaS platform in projects for the digital transformation of production and staff development.