Skip to content

Sensor metrics collection with BME280, storage in PostgreSQL and Grafana dashboard on Raspberry Pi

License

Notifications You must be signed in to change notification settings

inemov/home_monitoring

Repository files navigation

Home environmental monitoring

Sensor metrics collection with BME280, storage in PostgreSQL and Grafana dashboard automatically loaded in kiosk mode on Raspberry Pi.

image

Hardware

Software

sudo apt install postgresql
sudo su postgres
createuser pi -P --interactive

Provide password 'home_monitoring' and allow the pi role to be a superuser. Exit from the postgres user:

Ctrl-q

Table 'home_monitoring' will be created automatically by python script.

  • Install Grafana
sudo apt install grafana

Peform following changes in Grafana settings:

cd etc\grafana
sudo nano grafana.ini

Change following parameters:

disable_sanitize_html = true
allow_embedding = true
enable_alpha = false

Exit from editor Ctrl-X and save changes. Restart Grafana service:

sudo systemctl restart grafana-server

If necessary, replace files on Raspberry Pi to match files in the repository etc and usr folders.

  • Install python and create virtual environment:
sudo apt install python3
sudo apt-get install python3-venv
python3 -m venv sensor_dev

Activate the virtual environment:

workon sensor_dev

Install necessary libraries:

pip3 install psycopg2
pip3 install smbus2
pip install bme280
  • Put scripts in target folder and configure autostart: Copy files from repository \home\pi\home-monitoring to corresponding location on Raspberry Pi.
sudo nano /etc/xdg/lxsession/LXDE-pi/autostart

Add at the end to automatically start three scripts after reboot:

@/home/pi/home-monitoring/sensor2db_activation.sh 
@/home/pi/home-monitoring/chromium_start.sh 
@/home/pi/home-monitoring/chromium_refresh.sh
  • Copy Grafana dashboard Home monitoring-1642299995636.json from the repository and import it in Grafana interface (http://localhost:3000)

Logon information summary

RPI

login: pi@rpi-homemonitoring password: home_monitoring

python venv

name: sensor_dev

PostgreSQL

user: pi password: home_monitoring database: pi table: home_monitoring host: localhost port: 5432

Grafana

user: pi password: home_monitoring

About

Sensor metrics collection with BME280, storage in PostgreSQL and Grafana dashboard on Raspberry Pi

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published