Environmental monitoring

Bob Mottram fc2b5e9f6d Add avahi 4 years ago
daemon 003d556e1a Change install directory 4 years ago
man fc2b5e9f6d Add avahi 4 years ago
src 04352d49fd Fix warnings 4 years ago
LICENSE f36f1655b2 Initial 4 years ago
Makefile 3bd15ad813 Change install instructions 4 years ago
README.md fc2b5e9f6d Add avahi 4 years ago


Environment monitoring with bme280/Si1132 Weather Board

This allows you to monitor an environment for temperature, pressure, humidity, UV and ambient light using the bma280 and Si1132 sensors, which can be interfaced to many small single board computers.

Sensor specifications


On Debian based systems install some packages:

sudo apt-get install git nginx gnuplot build-essential avahi-utils

Then get the source and build:

git clone https://github.com/bashrc/environment
cd environment
sudo make install
sudo useradd -d /environment-data/ -s /bin/false environment
sudo chown environment:environment /environment-data


Run unit tests with:

sudo ./environment --tests

To test that the sensor is working:

sudo ./environment --demo

With CTRL-c to exit.

Deploying the daemon

sudo systemctl daemon-reload
sudo systemctl enable environment
sudo systemctl start environment

By default web content will be saved into:


You can then browse to the avahi local address of the system to view the graphs.


The following commend options are available.

 -d --device [path]       i2c device path
 -f --freq [sec]          Sampling frequency in seconds
 -l --logdir [directory]  Logging directory
 -w --www [directory]     Web page directory
 -t --tests               Run unit tests
    --title [string]      Title of web site
    --width [pixels]      Width of graphs in pixels
    --height [pixels]     Height of graphs in pixels
    --daemon              Run as a daemon

You can use these to tweak the systemd daemon. For example to change the title of the web site to indicate where the sensor is located:

sudo systemctl stop environment
sudo sed -i 's|ExecStart=.*|ExecStart=/usr/local/bin/environment --daemon --title "My Living Room"|g' /etc/systemd/system/environment.service
sudo systemctl daemon-reload
sudo systemctl start environment


Suppose that you want to use temperature to trigger some action. You can obtain it with:

tempval=$(curl mydevice.local/Temperature | awk -F '.' '{print $1}')
if [ $tempval -gt 28 ]; then
    echo "It's too hot!"

You can also do the same with the values Pressure, Humidity, Visible, IR, and UV.