AqiSDS011 - Android AQI app
Tags: sds011, android, airquality
Published: 2021-03-21 20:38:38

In the previous two posts in this series, you could read a bit more about out-of-the-box ways to use the SDS011 air quality sensor. At first, I connected the sensor to my laptop but then I realized that my mobile phone could be a more portable appliance accomplishing the same purpose.

## Using the existing sds011_android app

After some time spent using a sensor with my mobile phone and the [sds011_android application found on the GitHub](https://github.com/milosevic81/sds011_android), I realized there are few features that would make this application even more usable:
- UI should reflect [proper colours for air quality according to the PM2.5 or PM10 levels](https://uk-air.defra.gov.uk/air-pollution/daqi?view=more-info&pollutant=pm25#pollutant)
- save/view a history of measurements
  - date, time & location included
  - show location for each measurement on the map
  - this way we can take a ride or walk around the town and later analyze data to see if air quality differs between different locations
- pause/continue measurements
  - this would save the sensor laser & my phone battery
- configure periodic measurements
  - this would save the sensor laser & my phone battery

I didn't touch Android development for quite a long time but I felt it shouldn't be too hard to implement at least some of the above-mentioned features. Since I wanted to have such an application for my own usage and I hoped something like that could be useful to other people I decided to spend some time on the project I named [the Mobile Air Quality Monitor application for the SDS011 Sensor](https://github.com/vvidovic/aqi-sds011).

## AqiSDS011 - the android app

The current result is available on GitHub as [the AqiSDS011 repository](https://github.com/vvidovic/aqi-sds011). I will need some more time to prepare and publish it as an application on the [Google Play Android app store](https://play.google.com/store/apps).

Before I do that, anyone wishing to use the application will (unfortunately) need to build and run the application herself/himself which is not an easy task for a non-developer. This task can be accomplished using the Android Studio, [as described in the official tutorial](https://developer.android.com/training/basics/firstapp/running-app).

I am thankful to the developers of [the sds011_android project](https://github.com/milosevic81/sds011_android) and the developers of [the aqi project](https://github.com/zefanja/aqi) - without these two projects, it would be much harder to implement the AqiSDS011 project. I copied parts of the logic for interaction with the SDS011 sensor from the sds011_android application and logic for calculating the AQI indices for PM2.5 and PM10 from the aqi Python logic.

### The modes of operation of the SDS011 sensor

The SDS011 sensor has two data reporting modes:
- Active reporting (used by AqiSDS011 and the sds011_android projects)
  - when this mode is enabled, the sensor sends measuring data without additional queries
- Query reporting (used by aqi project)
  - when this mode is enabled, the sensor waits for query before measuring and sending the measuring data back to the connected appliance

When the active data reporting is used, the sensor can work in one of two modes:
- sending data continuously (each second)
- sending data each n minutes (depending on settings sent to the sensor)

AqiSDS011 supports both modes of active data reporting.

### The current status of the AqiSDS011

Currently, the project finally implemented the list of basic requirements through 3 screens.

![The main screen - the current info](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/bt7tq2eibnsotflfp4i9.png)

The main measurements screen shows the current AQI information and enables you to start or stop the measuring process. This is a screen where you can choose between the continuous measuring mode and the periodic measuring mode.

![The history screen](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/0ubtms3gi3omchm5ejh3.png)

The history screen shows all saved measurements but also enables you to:
- save the history information
- clear the history
- open the map application to show you the location for the saved measurement

![The settings screen](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/6b8oesf98gyjuydyo4od.png)

The settings screen enables you to:
- enter the length of the work period (applied when you use the application in the periodic mode).
- enter the number of measurements (equals the number of seconds) for averaging before saving to history
- select the location data gatherings setting

### The road ahead

While AqiSDS011 became an application with all initially envisioned features, there are still a few issues I would like to do or at least investigate. For example:
- prepare a description and publish AqiSDS011 to the Google Play app store
- check if converting a part of the application to the service would make AqiSDS011 more reliable for the long-running measurements

Cover image by [Reimund Bertrams](https://pixabay.com/users/8385-8385/?utm_source=link-attribution&amp;utm_medium=referral&amp;utm_campaign=image&amp;utm_content=2462053) from [Pixabay](https://pixabay.com/?utm_source=link-attribution&amp;utm_medium=referral&amp;utm_campaign=image&amp;utm_content=2462053).