meta data for this page
  •  

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
groups:mg:mg:temperture_monitoring [2018/08/20 09:17] – [Creating the database] rholstgroups:mg:mg:temperture_monitoring [2018/09/04 12:40] (current) – removed ssauer
Line 1: Line 1:
-====== Temperature Monitoring with Raspberry Pi ====== 
  
-FIXME use %%''...''%% for folders or names and %%<code>...</code>%% for actual commands or text documents 
- 
-FIXME add grafana 
- 
-FIXME add overview of all important files and services 
- 
-FIXME Write down account names and passwords somewhere 
- 
-FIXME add overview of the general structure of the setup 
- 
-FIXME add "Important: it gets automatically new slaves but doesn't support removing slaves while running." 
- 
-FIXME add console prompt to code segments 
- 
-The monitoring setup was developed by Etiénne Wodey. It is explained in {{ :groups:mg:mg:2016-08_geoq_ctp_ew.pdf |this talk}} by him. The main aspects on how to set it up are documented in {{ :groups:mg:mg:w1_stuff.eml |this email}}. 
- 
-===== Database and Visualisation ===== 
- 
-  * thingol (server name) 
-    * debian 9 
-    * [[https://www.influxdata.com/time-series-platform/influxdb/|influxdb]] 
-      * time series database 
-      * used for storing temperature values 
-      * set up as decribed in [[https://docs.influxdata.com/influxdb/v1.5/introduction/getting-started/|getting started section]] 
-    * [[https://grafana.com/|Grafana]] 
-      * used for visualisation of the values stored in influxdb 
- 
-===== Raspbery Pi ===== 
- 
-==== Basic principle ==== 
- 
-{{:groups:mg:mg:rasptemp1.jpg?600|}} 
- 
-{{:groups:mg:mg:rasptemp1.pdf |}} 
- 
-==== Hardware setup ==== 
- 
-FIXME pictures and schematics 
- 
-==== Installing Raspbian ==== 
- 
-==== Enabling One-Wire-Bus ==== 
- 
-Edit ''/boot/config.txt'': 
-<code> 
-sudo nano /boot/config.txt 
-</code> 
-and add the line 
-<code> 
-dtoverlay=w1-gpio 
-</code> 
- 
-Edit ''/etc/modules'': 
-<code> 
-sudo nano /etc/modules 
-</code> 
-and add the lines 
-<code> 
-w1-gpio 
-w1-therm 
-</code> 
- 
-Reboot the System: 
-<code> 
-sudo reboot 
-</code> 
- 
-There should be folders ''w1_bus_master<N>'' in ''/sys/devices'': 
-<code> 
-ls -l /sys/devices/ 
-</code>  
- 
-Check if there are devices connected: 
-<code> 
-ls -l /sys/devices/w1_bus_master1/ 
-</code> 
-Replace ''w1_bus_master_1'' with any of the folders listed previously. 
- 
-There should be folders named something like ''3b-0000001760f8/''. These are the devices connected. Make sure there is a file named ''w1_slave'' for every device connected. This file is used to read from and write to the connected devices. 
- 
-In case the folders or the files don't exist, make sure your devices are connected correctly, the steps above were done and/or reboot the system. 
- 
-==== collectd ==== 
- 
-https://collectd.org/index.shtml 
- 
-''collectd'' is run on the raspberry pi to read out the temperature sensors and send the messages to the influxdb database located on another server. 
- 
-install collectd: 
-<code> 
-sudo apt-get update 
-sudo apt-get install collectd 
-</code> 
- 
-check the status of the daemon: 
-<code> 
-sudo systemctl status collectd 
-</code> 
- 
-if the status is running, stop the daemon: 
-<code> 
-sudo systemctl stop collectd 
-</code> 
- 
-to view all systemlog messages by collectd: 
-<code> 
-journalctl -u collectd -b 
-</code> 
- 
-The collectd configuration file is located at /etc/collectd/collectd.conf. Edit it: 
-<code> 
-sudo nano /etc/collectd/collectd.conf 
-</code> 
-Copy the contents of {{ :groups:mg:mg:collectd.txt |this file}} into there. 
- 
-Make sure to adjust the name of the server in the network plugin section to your needs. 
- 
-==== Python Plugin ==== 
- 
-The temperature sensors are read out by a python module using the python plugin for collectd. Place the script {{ :groups:mg:mg:w1_therm_monitor.py |}} in the folder ''/home/pi/'' or change the ModulePath option for the python plugin in ''/etc/collectd/collectd.conf'' if you want to place it in another folder. 
- 
-The collectd module reads ''w1_master_slaves'', takes all the serial numbers starting with ''28'' (DS18B20 family) or ''3b'' (MAX31850 family) and reads the corresponding slave files (i.e. the temperatures). 
- 
-==== Starting collectd ==== 
- 
-Start the collectd service using: 
-<code> 
-sudo systemctl start collectd 
-</code> 
- 
-Check if it runs without errors by reading 
-<code> 
-sudo systemctl status collectd 
-</code> 
-or checking 
-<code> 
-journalctl -u collectd -b 
-</code> 
- 
-<note important>The system automatically gets new slaves but doesn't support removing slaves while running</note> 
- 
-===== influxdb ===== 
- 
-[[https://www.influxdata.com/time-series-platform/influxdb/|]] 
- 
-==== Setup ==== 
- 
-set up as decribed in [[https://docs.influxdata.com/influxdb/v1.5/introduction/getting-started/|getting started section]] 
- 
-==== Creating the database ==== 
- 
-Create a database in which you later wish to store the temperatures measured, for now we call it ''collectd_test''. 
- 
-In influxDB execute: 
-<code> 
-CREATE DATABASE collectd_test 
-</code> 
- 
-Check if it was created properly using: 
-<code> 
-USE collectd_test 
-</code> 
- 
-Exit using  
-<code> 
-EXIT 
-</code> 
- 
-==== Configuring for collectd ==== 
- 
-Stop the influxdb server by running: 
-<code> 
-sudo systemctl stop influxd 
-</code> 
- 
-The configuration file is ''/etc/influxdb/influxdb.conf''. The documentation can be found here: [[https://docs.influxdata.com/influxdb/v1.6/administration/config/]] 
- 
-The config file we use is {{ :groups:mg:mg:influxdb.txt |this}}. 
- 
-The interesting part is: 
-<code> 
-[[collectd]] 
-  enabled = true 
-  bind-address = ":25826" 
-  database = "collectd_test" 
-  security-level = "none" 
-</code> 
- 
-This enables the collectd plugin for influx and writes to the database we specify without any privileges required. 
- 
-adjust the configuration file to be the same as above. 
- 
-==== types.db ==== 
- 
-The collectd plugin for influx requires a types.db document. Copy this from ''/usr/share/collectd/'' on the raspberry pi to ''/usr/local/share/collectd/'' on the server running influxDB. 
- 
-==== Restarting the server ==== 
- 
-Start the server by typing <code>influxd</code> and leave the terminal open. If there are any errors, these should be displayed now. 
- 
-To check if there are values being written into the database, use another terminal or ssh to log into influx: 
-<code> 
-influx 
-</code> 
-and check for values in the database: 
-<code> 
-USE collectd_test 
-SHOW SERIES 
-</code> 
- 
-If something is displayed, try listing those values by using 
-<code>SELECT * FROM <name of the time series></code>