Contains various Ansible roles for setting up a home sensor network on a Raspberry Pi server. Described in more detail in the blog post series on creating a home sensor network.
Currently it contains the following roles in the /ansible-playbooks/roles
directory, which can all be run from the home-sensor-network-setup.yml
playbook with you hosts file e.g.
ansible-playbook home-sensor-network-setup.yml -h your-hosts-file.ini
Variables can be set in the files in the /vars
directory, specifically sensor-vars.yml
and a file mqtt-passwords.yml
, for the format of the latter copy example-mqtt-passwords.yml
and rename it, and add your own password and username.
Only used for Vagrant boxes to create a user called ‘pi’ that can be used to run the other playbooks against as a test. Will use a SSH key at /keys/pi-server.pub
, which is not in this repository and you should use your own.
This playbook is provisioned in the vagrantfile, and once run all other playbooks can run with the ‘pi’ user as the installation user.
This will run all of the roles one after the other and install the complete home sensor network onto your host, using the variables set in the files imported from the vars
directory, which will then overwrite any variables set in then defaults
directory of each role.
Comment out the ones you don’t need.
Raspberry Pi specific optimisation that changes the memory split to reduce the amount the GPU gets, as we’re not running a display.
Basic Debian/Raspberry Pi OS server setup that ensures basic security and admin steps.
Creates a SQLite database that downloads and stores the regular observations recorded by the Deutsche Wetterdienst (DWD), mostly using the Python script get-dwd-weather-data and sets up an appropriate cron job.
Sets up a Mosquitto MQTT broker, and installs the store-mqtt-data script, as well as associated SystemD unit files and passwords so data from temperature sensors and utilities can be sent to it, and then recorded in an SQLite database.
Installs a simple Python script and cron job to back up a database on a daily basis, and save it as a zipped tarfile.
Don’t run this on the open internet!
This uses whatever old version of Nginx is in the distro’s repositories, doesn’t run any firewalls of it’s own etc. Therefore it’s only safe to use on private network behind a network firewall.
This installs an Nginx server, along with the WSGI server Gunicorn, and the Python Flask based Home Sensor Website.
The server will create a self-signed certificate, and serve the page on both HTTP and HTTPS (to which most modern browsers will re-direct you). This is likely to cause a warning on your browser, and you’ll have to click ‘Advanced’ or something to accept the risk that this connection is self-signed.
The defaults will create an example installation with dummy data, and think it’s set to the domain ‘example.com’.
You will want to create an additional variables file vars/webview-vars.yml
such as the domain name, and that is_test: false
so that it installs the templated configuration file that tells it where to find the Sqlite database with the data created by the MQTT server. See vars/example-webview-vars.yml
.
Depending on your server, you may want to edit the SystemD service file in the templates
directory and change the number of workers for Gunicorn. It is set it to only 1 worker, as this is deployed on a v1 Raspberry Pi with a measly 512MB of RAM, and more than one worker caused them to continuously crash and restart because of out of memory errors.