Measuring Co2 and Temperature in closed environments (office, home).
People are sensitive to high levels of Co2 in closed envorinments, so we want to have some numbers to monitor it.
-
TFA-Dostmann AirControl Mini CO2 Messgerät -- 80 euro
-
Raspberry PI 3 -- 40 euro
-
case, 5v power supply, microSD card
-
Install on your Raspberry PI 3 InfluxDB & Grafana.
-
download Raspbian and install it on the microSD. We used this version of raspbian.
-
Boot the raspberry with the raspbian. You'll need a USB-keyboard, monitor and ethernet for this initial boot. After overcoming the initial configuration screen, you can login into the box using ssh.
-
install python libs
sudo apt-get install python-pip python-dev libyaml-dev
sudo pip install pyyaml
sudo pip install requests
- create
config.yaml
:
prefix: office.floor3
2b) (optional) You can configure this bot to automatically post to a Slack channel.
Just add an "Incoming Webhook" to your Slack team's integrations and add a slack
hash to the config file.
slack:
webhook: 'https://hooks.slack.com/services/TXXXXXX/XXXXXX/xxxxxxx'
channel: '#general' # optional - this is the default value
botname: 'CO2bot' # optional - this is the default value
icon: ':monkey_face:' # optional - this is the default value
upper_threshold: 800 # optional - this is the default value
lower_threshold: 600 # optional - this is the default value
- fix socket permissions
sudo chmod a+rw /dev/hidraw0
- run the script
./monitor.py /dev/hidraw0
- run on startup
To get everything working on startup, need to add 2 crontabs, one for root and the other for the pi user:
Roots:
SHELL=/bin/bash
* * * * * if [ $(find /dev/hidraw0 -perm a=rw | wc -l) -eq 0 ] ; then chmod a+rw /dev/hidraw0 ; fi
Pi:
SHELL=/bin/bash
* * * * * /usr/bin/python /home/pi/monitor.py /dev/hidraw0 [ **optional:** /home/pi/my_config.yaml ] > /dev/null 2>&1
The script will default to using "config.yaml" (residing in the same directory as the monitor.py script - /home/pi in the example) for the librato credentials. You can optionally override this by passing a custom configuration file path as a second parameter.
- In the project folder create the
config.yaml
file as described in the chapter for the manual installation process. Replace the line containing theprefix
assignment by:
prefix: {{ name }}
based on code by henryk ploetz based on code by Wooga