Follow the temperature of a birdhouse: A Raspberry Pi and two probes DS18B20


nichoir_250px the discovery of dead broods cold or warm in a nest box pushed me to measure the temperature in mine, then to know the gap with the outside temperature.
A Raspberry FT2 B already being used to view the litters I decided to add two temperature sensors digital DS 18 B 20, one that will be placed in the nest box one foot out.


NIVEAU_debutant

click to read the definition of the levels



the idea


is the discovery of dead litters of warm or cold in a birdhouse that pushed me to carry out this monitoring. I already described a few months ago the realization of a webcam for nest box . A Raspberry FT2 B already being used to view the litters I decided to add two temperature sensors digital DS 18 B 20, one inside the nest, the other outside.


starting configuration


Raspberry Pi 2 works under Raspbian Wheezy kernel 4.1.19 . It is connected to the PC via Ethernet. He pilots a camera v1 , and via ports GPIO lighting of the nest box (white and infra-red light) and the infrared cut filter.


the PC runs with Archlinux distribution. A web interface command camera, LED and filter. It sends other commands to the FT2 by SSH connection.


in the suite I kept the IP addresses and identifiers in clear ( in the NSA already intercepted them 😉). They are to adapt to your case.


installation of sensors


article of Francis ‘ with the Raspberry Pi DS18B20 1-wire temperature measurement ‘ (source 1) was a good starting point.


wiring


cablage_600px


the GPIO 4 being already taken I connected the 2 components to the GPIO 17 (physical pin 11).


implementation


open / etc/modules with nano in root and add the necessary modules: w1-gpio and w1-therm .


open / boot/config, txt with nano in root and add the lines:


 # 18B DS 20 dtoverlay = w1-gpio temperature probe, gpiopin = 17 

here, the parameter gpiopin is essential because I do not use GPIO 4. This is the default GPIO and not not required as well written often. Attention, the number to be indicated corresponds to the numbering GPIO BCM .


finally reboot.


now we can know the identifiers of the probes:


pi@raspberrypi ~ $ ls/sys/bus/w1/devices / 28-000007f0acfc 28-000007f0c9f5 w1_bus_master1 pi@raspberrypi ~ $

and ensure that they work:


pi@raspberrypi ~ $ cat/sys/bus/w1/devices/28-000007f0acfc/w1_slave 57 01 4b 46 7f ff 09 10 c7: crc = c7 YES 57 01 4B 46 7f ff 09 10 c7 t = 21062 pi@raspberrypi ~ $ pi@raspberrypi ~ $ cat/sys/bus/w1/devices/28-000007f0c9f5/w1_slave 4 d 01 4b 46 7f ff]] 03 10 d8: crc = d8 YES 4 d 01 4b 46 7f ff 03 10 d8 t = 20875 pi@raspberrypi ~ $

to determine the correspondence between ID and component, simply put your finger on one of the two and see what temperature rose…


use of munin


wanting to retrieve automatically measures and arrange them in curves I used 2 items on COP’s blog:


– Temperature followed with a Raspberry Pi B +, a Sensor DS18B20 and Munin ( source 2 )


– track the status of its server with Munin ( source 3 )


Installation


on the PC just install the program supervisor munin . However it is interesting to also install the utility to recover data munin-node to verify that the local configuration is already correct.


on the Raspberry one Pi munin-node is to install:


pi@raspberrypi ~ $ sudo apt - get install munin-node 

Configuration


I’ve used Wiki Archlinux on munin (source 4). Adaptations are necessary according to your distribution


on the PC


in Archlinux type Server data is stored in the directory /srv http in and / srv/http . This is to create the directory where munin follow the measures, graphics and web pages; and give it the correct owner.


 # mkdir/srv/http/munin chown munin:munin/srv/http/munin 

/etc/munin/munin.conf Edition (as root)


in beginning of file, under the line #htmldir/usr/share/munin/www , add: htmldir/srv/http/munin


either uncomment the line (remove the # which is at the beginning of line) and enter the right directory.


the section # a simple host tree in [localhost]


 [localhost] address 127.0.0.1 use_node_name yes 

Add the reference of the Raspberry to supervise: [raspberrypi]


 [raspberrypi] 192.168.7.8 address use_node_name yes 



ATTENTION!


The name between the hook must be identical with the host name of the Raspberry. I kept the default host name.



munin-node (if installed)


start it and at the same time to allow my startup at boot;


 # systemctl enable - munin-node now 

to see the plugins (scripts to collect information) used, enter the command:


 # munin-node-configure - suggest 

as munin-node runs only the plugins present or referenced in the directory / etc/munin/plugins , simply create symbolic links to the plugins you interesting.


 # ln s/usr/lib/munin/plugins /-plugin/etc/munin/plugins /-plugin 

If you want all the command


 # munin-node-configure - shell | sh 

is much faster;).


restart munin-node so that it takes into account the selected plugins:


 #systemctl restart munin - node.service 

automation of the statement of the monitored information


it’s possible with the classic cron . But I chose to try with systemd that allows to use timers (timers in English).


first create ad-hoc service: file /etc/systemd/system/munin-cron.service


 [Unit] Description = measurement on the monitored nodes After = network.target [Service] use = ExecStart = / usr/bin/munin-cron munin 

then create the timer: file /etc/systemd/system/munin-cron.timer


 [Unit] Description = data taking all the...

[Timer] OnCalendar = *-*-* *: 00/7:00 [Install] WantedBy = multi - user .target

the syntax for OnCalendar is as follows:
an optional indication of name (s) of day of the week in English (absent here) followed by a space,
aa-mm-jj; Here the stars indicate to any (the) year, month, day number; space
hh; here at any time, and the second 0, for minutes the / indicates the repetition, 00 minute departure and 7 for example the value to add.
Thus the munin-cron service will be triggered each minute 0, 7, 14 or 21 or… 56 then 0 again (and not 3 from 56 + 7 = 63 and 63-60 = 3).
Now we must recharge systemd configuration, start the timer and allow my startup at boot.


 # systemctl daemon-reload # systemctl enable - now munin - cron.timer 

firstage verification


in the browser enter the address: file:///srv/http/munin/index.html
Vous should see the homepage of munin with localhost as the single node.] After a while the graphics corresponding to the selected plugins should appear, with more and more values according to the pace set in the timer. For values of timer of 5 minutes or more the update of the page in the browser is done automatically at the selected rate (about 2-3 minutes after the reading of the data).
In case of trouble, it is wise to check the log files in / var/log/munin .


on the FT2


install munin-node:


pi@raspberrypi ~ $ sudo apt - get install munin-node 

all the symbolic links to usable plugins are created in / etc/munin/plugins .]


to check the proper functioning between the Pi and the PC just keep one or two plugin (s):


pi@raspberrypi ~ $ ls-l/etc/munin/plugins pi@raspberrypi ~ $ sudo rm/etc/munin/plugins/plugin-no-wanted 

it remains to set up munin-node


pi@raspberrypi ~ $ sudo nano etc/munin/munin-node.conf

check the host name and possibly change.] I preferred to enter it.


reminder : it must be the same as entered in /etc/munin/munin.conf in the PC. [


 # set this if the client doesn't report the correct hostname when # telnetting to localhost, port 4949 # host_name raspberrypi 

allow the PC to connect by adding following


 allow ^127.0.0.1$ allow ^: $1 

the line with the IP address of the PC


 allow ^ 192.168.7.1$

for this new configuration is taken into account , restart munin-node:


pi@raspberrypi ~ $ sudo service munin-node retstart 

on the PC the reloading of the page file:///srv/http/munin/index.html must show raspberrypi in addition to localhost then the (graphic (s) with the (s) plugins retained (s).]


the “temperatures” plugin


this plugin temperatures (sans accent) is a bash script. To write it I analyzed the plugin load well commented and the plugin cpu to understand how to plot several curves in the same chart. Naturally the reference manual of the plugins for munin has been of great use ( source 5 ).


 #! / bin/bash if [ "$1" = "config" ]; then echo 'graph_title Temperature in and out box' echo 'graph_order birdhouse out gel' echo 'graph_args-r - lower-limit-20 - upper-limit 50' echo '400 graph_height' echo 'graph_width 800' echo 'graph_vlabel Celsius' echo 'graph_printf %.1lf' echo 'graph_info comparison of temperatures in and out of the nest box' echo 'graph_category birdhouse' echo 'graph_period minute' echo 'nichoir.label birdhouse' echo 'nichoir.draw LINE' echo 'nichoir.colour cc2200' echo 'nichoir.info Temperature in the nest box' echo 'dehors.label out' echo 'dehors.draw LINE' echo ' ({({dehors.colour 1144ff' echo 'dehors.info Temperature outside the nest box against him' echo 'gel.label Gel' echo 'gel.colour 000022' exit 0 fi GEL = 0 $(cat /sys/bus/w1/devices/28-000007f0acfc/w1_slave | grep "t=" | awk-F "t=" 'printf("%.1fn", $2/1000) = BOX') OUT = $(cat /sys/bus/w1/devices/28-000007f0c9f5/w1_slave | grep "t=" | awk-F "t=" 'printf("%.1fn", $2/1000)') printf "%i %.1fngel.value %.1fndehors.value nichoir.value" $NICHOIR $DEHORS $GEL 

I chose a range of temperatures from-20 ° to 50 ° (it should be wide enough for Toulouse ;)) where graph_args parameters;) r (rigid) prevents an automatic adjustment of the vertical scale.


height x width of 400 × 800 size I was most pleased. If the default 200 × 400 size 2 matching rows are intiles.


attention the argument to set the line color is colour with the u (British English) and not color (anglais américain); the setting is the hexadecimal code red green blue RRGGBB without sharp.


as the probe measurement accuracy is ± 0.5 °, I chose to keep only a single decimal place for the temperature values; where the 1 in the printf %.1f and graph_printf %.1lf parameters.


but doing this variable GEL, and more set at 0 and therefore in fact a constant? The horizontal line command no longer works with munin 2.0.x. Wanting a well marked 0 ° line I found this way.


in order to have all the curves in the same graph must group the values in a single printf where the last command bringing together the 3 rules of formatting and the content of the 3 variables.


this script is to be placed in the/etc/munin/plugins directory.


must make it executable:


pi@raspberrypi ~ $ sudo chmod 755/etc/munin/plugins/temperatures 

and tell munin-node to take into account:


pi@raspberrypi ~ $ sudo service munin-node retstart 

with a web server on the PC?]]


If you do not view the graphs with another computer is not necessary. [Justuseinabrowsertheaddress: file:///srv/http/munin/index.html


however do it from another machine to have a web server installed and running on the PC. In my case I had already lighttpd on the PC. I had the good surprise to see that without any additional adjustment worked immediately:


– address in the browser on the PC (just for checking): http://localhost/munin
– address in the browser of another machine connected to the LAN: http://192.168.7.1/munin


the PC runs under Archlinux with munin in version 2.0.26 and lighttpd version 1.4.43.


test


to be able to test negative temperatures I soldered a probe to a cable 3 conductors with a length of 12 meters to reach the refrigerator with freezer part. I wrapped this probe in a little film microwave and put it in the bottom of the refrigerator and then in 2 places in the freezer then return. Meanwhile the other probe remained well warm in the test Board.


here’s the graph obtained with a 5 minute measurement rate:


Courbe de température obtenue avec 2 sondes

click to enlarge



this project is intended to be installed in the nest box at the side of the Raspberry FT2 of the camera with my cup-infrared filter and LED lighting. I set the temperature to 10 minutes reading rate.


at the moment everything is wired on board test but with the camera connected to the Raspberry. I have noted with pleasure that it does not disturb in any way nor the operation of camera, nor the web command of it. Simultaneously, I can see the video transmitted by the Pi and the updates of the temperature readings.


  1. https://href.li/?http://www.framboise314.fr/mesure-de-temperature-1-wire-ds18b20-avec-le-raspberry-pi/

  2. https://href.li/?https://blog.bandinelli.net/index.php?post/2014/11/23/Temp%C3%A9rature-suivie-avec-un-Raspberry-Pi-B%2C-une-sonde-DS18B20-et-Munin

  3. https://href.li/?https://blog.bandinelli.net/index.php?post/2013/10/13/Suivre-l-%C3%A9tat-de-son-serveur-avec-Munin

  4. https://href.li/?https://wiki.archlinux.org/index.php/Munin

  5. https://href.li/?http://guide.munin-monitoring.org/en/latest/reference/plugin.html


No comments:

Powered by Blogger.