Skip to content
An easy way to collect and display data about the air we breathe
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
LICENSE
README.md
clean.py
collect.py
humidity.csv
index.html
pm1.csv
pm10.csv
pm2.csv
screenshot.jpg
temperature.csv

README.md

graph-air

An easy way to collect and display data about the air we breathe. Use this project along with my air-multisensor project to get the graphs I've shown below. Note: this project relies on HighCharts to display the data.

Alt text

Installation

You need Python 3. Run python3 collect.py either through linux/cron, or use a watch command as follows:

watch -n 60 python3 ~/beautiful-air/collect.py

You need any web server to host the csv files, as well as the index.html. A simple Python web server can be started as follows:

cd ./beautiful-air/
python3 -m http.server 8080

Both can be integrated into /etc/rc.local so that the scripts will run on boot. I add a twist by running each command in a screen, a virtual terminal that allows reconnection:

su -c "cd ~/beautiful-air/ && screen -dmS miniserver python3 -m http.server 8080" -s /bin/sh pi
su -c "cd ~/beautiful-air/ && screen -dmS collect watch -n 60 python3 ~/beautiful-air/collect.py" -s /bin/sh pi
#      directory of csv/html.          friendly name   update interval     path to collect.py             username

Customizations

The modular form of this project means that you can easily add or erase blocks of code from both index.html and collect.py and add any sensor of your choice. Duplicate a csv file, rename it, and change the header/labels. Add a url request, and add your new file to collect.py. Copy/edit a block from index.html, and change the url to your own. Use the humidity code block as a template for a single sensor plot, or the particulate matter one for multiple plots.

Troubleshooting

If the charts aren't displaying properly, this could mean there are inconsistencies in the ordering for your time values. If the times aren't strictly increasing, highcharts runs into some problems. Run clean.py in the directory with your .csv files.

You can’t perform that action at this time.