Python ML Analyzing Air Quality Obtained from SDS011 Sensor via VB6/PHP

I have been so desperate to measure air quality inside my room because I have neighbors that burn their garbage and most often all of those polluted air find its way inside my room, some of them burn their garbage at night sometimes even during wee hours of the morning. Their habits is unpredictable. I tried to look at shopee or lazada but there is no such device that records air quality and at least save it to an sd card. So I was forced to buy the SDS011 sensor, the one with USB adaptor to enable to create a software that will read the sensor's readings, save it to a database and use Machine Learning to discover patterns and predict the effects of the air that gets into my room(optional).

I thought, after connecting the sensor to my pc and downloading the required driver, I could already use the readings right away, but it was not that easy, the output was in the form of binary data, so I will need to find a way to decode it. Being a VB6 developer in the past, my first choice of programming language to use is VB6 but it is not fully equipped with the tools I need, it can read the data coming from the sensor but it could not decode the data so I need to do some research and found out that PHP can decode it easily, and PHP is very flexible, it can easily save the decoded data to MySql database and send back the decoded data to the VB6 application. I could have chosen PHP or VB6 to do the data anaylsis part but both languages are not equipped with the libraries/ocx components to do the task that is why I still need python. I will be using Python for the analysis of decoded data and discover patterns and display the output as html file and this html file will be displayed in the VB6 front end or dashboard application. 

I am almost done with VB6 front end program and the PHP script is already working. I will soon do the data analysis module. You may download the source code of this project at my github repository.

VB6 Front End Program

The front end program shall consist of 2 executable files therefore 2 projects. One will be to display data analysis part and the other one is to display in realtime the decoded data. The latter is optimised for a 5.5" screen. This is to save on energy and for portability because sometimes I need to transfer the location to get more accurate readings. The realtime air quality monitoring is already working but still with a few bugs but generally it is working already.


Disclaimer: Based on my experiments, the php script works on certain php versions and WAMP servers. I know because I tried it on my other pc and it did not worked right away. And also, the programming algorithm and naming conventions are of no commercial quality because it is just a personal project. So if you cared to download, you may need to make a lot of improvements.

The Data Analysis Part

I will adopt the US Air Quality Index in determining air quality. See the chart below, I have sourced from this website. Air Quality Index varies from country to country, and since there is no comprehensive study on this subject here in the Philippines, it is appropriate that the US AQI Chart should be used.




And to determine the overall air quality, I'll just compute the overall air quality by getting the average of the computed pm2.5 and pm10. I am not an authority on this subject, so consider this as my own opinion.

Here is the screenshot of my dashboard:



I guess this end my post here for further updates pls visit my github repository.

Announcement:

A commercial software version of this project may be out soon!  This version will have more features and will support odor and hazardouz gas sensors.