DEV Community

Cover image for AqiSDS011 - Android AQI app
Vedran Vidovic
Vedran Vidovic

Posted on

AqiSDS011 - Android AQI app

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, 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
  • 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.

AqiSDS011 - the android app

The current result is available on GitHub as the AqiSDS011 repository. I will need some more time to prepare and publish it as an application on the Google Play Android app store.

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.

I am thankful to the developers of the sds011_android project and the developers of the aqi project - 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

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

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

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 from Pixabay.

Top comments (0)