Home - abyrne55/air-quality-monitor GitHub Wiki

EC463 Mini-Project: Air Quality Monitor

Contributors:

Anthony Byrne @abyrne55

  • Django frontend, website structure
  • html templates
  • plotting data
  • testing
  • sensor simulator
  • authentication

Huzefa Mandviwala @HuzefaMandvi

  • Django backend, SQLite db
  • sensor API
  • documentation
  • Trello management
  • authentication

Product:

Final deployment can be viewed @ https://airqual.burpg.space/

Sign in with test user to see the sensor simulator working:

Username: rhett

Password: bostonuni

For self-installation instructions, see Installation.

Goals:

The goal of this project was to create and deploy an application for air monitoring devices within the household. These theoretical devices are either temperature or humidity monitors. The application should allow secure logging in, receive data from a user's sensors, and plot that data in a friendly way.

Methods:

We decided to use the django framework for this project. We thought that the project lent itself nicely to the Model-View-Controller method that django employs - an object-oriented approach where users own sensors and sensors own data points. To store this data, we utilized the built-in SQLite database which is already integrated with django. This database is populated via python scripts, based on the defined models (i.e. sensors and datapoints).

The models we built are fairly simple. A sensor has a descriptive name, an owner (a user on the site), an API key, a unit of measurement, and finally contains the data associated with it. For sanity, we also implemented a maximum and minimum value, defined by the user, which the sensor should operate within. If the sensor were to exceed these defined bounds, it would trigger a "malfunction" boolean, signifying that something has gone wrong.

For authentication, we implemented the django built-in authentication system. Users can register on the website, and passwords are stored securely (hashed) in the backend. The admin user never has access to the raw text of a user's password, as this is unnecessary for authentication and unsecure. Users can register themselves, add sensors, view all of their own sensors, and view a plot of data from each sensor.

We utilized a javascript library called chart.js in order to plot the incoming data. The data for a given sensor is fed to the chart library, which constructs pretty graphs on the front end.

In order to simulate a sensor, we wrote a simple python script. It randomly pings the API with sample data (between 0.0-100.0) on one of a few test sensors every 5-30 seconds.

In order to actually send data, a GET request is sent to the url:

<base url>/add/<sensor_id>

along with an API key string and a decimal value. API keys are unique to each sensor, and any requests that do not use the valid API key for a given sensor are rejected.

Sensor Information Flow Diagram

Testing

We wrote unit tests inside the django app to test the functionalities of our webapp. Unit tests were created to test users, sensors, data, and the GUI. These test normal and abnormal inputs, so we can be sure that our webapp is functioning normally even when giving unexpected input.

To run our unit tests, follow the instructions on the Installation page and then run python3 manage.py test.

Agile Methods

We found trello to be indispensable for keeping us organized and on task throughout this project. Using trello, we planned two sprints of 5 days each (evenly dividing the 10 days we had after initially meeting). We broke the project down into discrete tasks, decided on a logical order for the tasks to be completed, and were thus able to stay on schedule and both work on separate parts while monitoring each other's progress. Our trello board can be viewed at:

https://trello.com/b/Aoukhr8w/air-quality-monitor-ec463

We designated two pre-release candidates. The first was a bare-bones skeleton of a working sensor API and a simple webapp. The second was a more fleshed out version, with prettier looking html and the authentication functionality, but still missing tests and a sensor simulation. Our prerelease candidates can be viewed at:

⚠️ **GitHub.com Fallback** ⚠️