Air quality sensor network sim
AirQuality is a service for collecting air quality readings from sensors attached to single-board computers, such as the Raspberry Pi. Readings are collected using a RESTful interface, then displayed in real-time using graphs. Sensors can be grouped into regions to create graphs averaging the results of all sensors in the region, instead of displaying individual sensor readings.
Final Project for Internet of Things class at Villanova University.
Made with Flask, jQuery, CanvasJS and Bootstrap, using MongoDB as a database backend.
RaspberryPi sender component written in C using WiringPi, libcurl and libconfig. Assumes use of MQ-2 Gas Sensor connected through a ADC0832 analog-to-digital converter.
- Install Python 2.7+, python-virtualenv and MongoDB on server
- Install the Python packages needed using virtualenv
1.
virtualenv airquality-venv
2.source airquality-venv/bin/activate
3.pip install -r requirements.txt
- Configure application server to point at airquality.app or start server.py
- Browse to http://127.0.0.1:5000 or wherever the server is running to see the user interface
- Obtain and connect MQ-2 Gas Sensor and ADC0832 (wiring diagram in rspi/mq-2_wiring.jpg)
- Install WiringPi, libcurl and libconfig on RaspberryPi (instructions in rspi/sender.c)
- Compile sender executable, modify config.cfg to point at running server, and start as root
In the rspi folder there is a simulator.py script that can send random readings similar to the ones generated by the MQ-2 sensor to a running AirQuality server. Change the URL in the script to point at a running server and run the simulator with the following command:
./simulator.py --config sim.txt
This will create a "sim.txt" file and populate with a random sensor ID if the file did not already exist, or will load the sensor ID from the file if it was already there. You can (and should) start multiple simulators when testing graphing of regional averages in the interface.