Measuring Co2 and Temperature at Woogas office.
People are sensitive to high levels of Co2 or uncomfortably hot work environments, so we want to have some numbers. It turns out that our office does vary in temperature and Co2 across the floors.
-
TFA-Dostmann AirControl Mini CO2 Messgerät -- 80 euro
-
Raspberry PI 2 Model B -- 40 euro
-
case, 5v power supply, microSD card
-
Librato account for posting the data to.
-
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 librato-metrics
sudo pip install pyyaml
sudo pip install requests
- create
config.yaml
with libratro credentials:
user: [email protected]
token: abc123...
prefix: office.floor3
We use librato to graph our weather, so you'll need to modify that if you using another service.
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.
based on code by henryk ploetz