Hallo,
ich habe vor, mit einem Rpi Model B Temperaturen mittels 1Wire Sensor zu messen und alle 5 Minuten in eine RRD zu speichern sowie, ebenfalls alle 5 Minuten, Graphen erstellen zu lassen.
Da der pi 24 Stunden, 7 Tage die Woche laufen soll habe ich folgendes Tutorial durchgearbeitet:
http://tech-weblog.net/raspberry-pi-l…7-dauerbetrieb/
Genauer gesagt Pi übertaktet, Memory Split verkleinert, watchdog aktiviert, und logs in der Arbeitsspeicher ausgelagert.
Da die Temperaturgraphen im Netz verfügbar sein sollen habe ich dieses Tutorial durchgearbeitet:
Raspberry Pi als Webserver - Apache 2 Installation
(alles bis auf FTP-Server installation).
Hier gibt es schonmal einen Fehler: der Apache startete nicht nach einem Neustart ohne logs. Also habe ich die Logs wieder aus dem Arbeitsspeicher geholt.
Die Temperaturen hole ich mir so wie hier in dem Tutorial:
http://webshed.org/wiki/RaspberryPI_DS1820
In /home/pi/test habe ich einen ordner "out", sowie die drei Dateien
"DS1820.rrd",
"temp.sh" und
"graph.pl".
Alle Dateien sind 755 und haben als owner/guppe pi:pi!
wenn ich jetzt alle minute (testweise) die scripte ausführen will per crontab:
*/1 * * * * /home/pi/test/temp.sh
*/1 * * * * /home/pi/test/graph.pl
bekomme ich in /var/mail/pi die Fehlermeldung im Anhang angezeigt:
/bin/sh: 1: /home/pi/test/temp.sh: not found
/bin/sh: 1: /home/pi/test/graph.pl: not found
Das komische ist, dass das ganze so schomal vor nem Jahr lief, mir dann allerdings die SD-Karte kaputtgegangen ist (crontab alle 5 minuten). Deswegen wollte ich zuerst die RRD und Graphen auf einen USBstick auslagern (/media/usbstick/), da gabs aber Probleme mit den Benutzerrechten...
bin echt am verzeifeln, habe schon einiges versucht!!!
Hier noch die scripte:
#!/usr/bin/perl
$mods = `cat /proc/modules`;
if ($mods =~ /w1_gpio/ && $mods =~ /w1_therm/)
{
;
}
else
{
$mod_gpio = `sudo modprobe w1-gpio`;
$mod_them = `sudo modprobe w1-therm`;
}
$temperature = 100;
while ($temperature <= -40 || $temperature >= 45)
{
$sensor_crc = `cat /sys/bus/w1/devices/10-0008022e24e7/w1_slave 1>&1`;
$sensor_crc =~ m/YES/;
if ($sensor_crc)
{
$sensor_temp = `cat /sys/bus/w1/devices/10-0008022e24e7/w1_slave 2>&1`;
$sensor_temp =~ /t=(\d+)/i;
$temperature = ($1/1000);
}
}
$rrd_out = `/usr/bin/rrdtool update /home/pi/test/DS1820.rrd N:$temperature`;
exit;
Alles anzeigen
#!/bin/bash
RRDPATH="/home/pi/test"
OUTPATH="/home/pi/test/out"
RAWCOLOUR="#FF0000"
TRENDCOLOUR="#0000FF"
# Edited 2012/12/9 to add running averages to hourly and daily graphs
#aktuell
rrdtool graph $OUTPATH/aktuell.png --start=-10800 --alt-autoscale --lower-limit=14 --upper-limit=20 \
DEF:temp=$RRDPATH/DS1820.rrd:temp:AVERAGE \
CDEF:trend=temp,3600,TREND \
VDEF:tempmax=temp,MAXIMUM \
VDEF:tempaverage=temp,AVERAGE \
VDEF:tempmin=temp,MINIMUM \
LINE1:temp$RAWCOLOUR:"aktuell" \
LINE1:trend$TRENDCOLOUR:"1h Mittelwert" \
COMMENT:"\n" \
COMMENT:"Maximum " \
COMMENT:"Average " \
COMMENT:"Minimum\n" \
GPRINT:tempmax:"%2.1lf%s°C" \
GPRINT:tempaverage:"%2.1lf%s°C" \
GPRINT:tempmin:"%6.1lf%s°C" \
#aktuell_big
rrdtool graph $OUTPATH/aktuell_big.png --start=-10800 --alt-autoscale --width 1024 --height 256 --lower-limit=14 --upper-limit=20 \
DEF:temp=$RRDPATH/DS1820.rrd:temp:AVERAGE \
CDEF:trend=temp,3600,TREND \
VDEF:tempmax=temp,MAXIMUM \
VDEF:tempaverage=temp,AVERAGE \
VDEF:tempmin=temp,MINIMUM \
LINE1:temp$RAWCOLOUR:"aktuell" \
LINE1:trend$TRENDCOLOUR:"1h Mittelwert" \
COMMENT:"\n" \
COMMENT:"Maximum " \
COMMENT:"Average " \
COMMENT:"Minimum\n" \
GPRINT:tempmax:"%2.1lf%s°C" \
GPRINT:tempaverage:"%2.1lf%s°C" \
GPRINT:tempmin:"%6.1lf%s°C"
#hour
rrdtool graph $OUTPATH/hour.png --start -6h --alt-autoscale --lower-limit=14 --upper-limit=20 \
DEF:temp=$RRDPATH/DS1820.rrd:temp:AVERAGE \
CDEF:trend=temp,7200,TREND \
VDEF:tempmax=temp,MAXIMUM \
VDEF:tempaverage=temp,AVERAGE \
VDEF:tempmin=temp,MINIMUM \
LINE1:temp$RAWCOLOUR:"stuendlich" \
LINE1:trend$TRENDCOLOUR:"2h Mittelwert" \
COMMENT:"\n" \
COMMENT:"Maximum " \
COMMENT:"Average " \
COMMENT:"Minimum\n" \
GPRINT:tempmax:"%2.1lf%s°C" \
GPRINT:tempaverage:"%2.1lf%s°C" \
GPRINT:tempmin:"%6.1lf%s°C"
#hour_big
rrdtool graph $OUTPATH/hour_big.png --start -6h --alt-autoscale --width 1024 --height 256 --lower-limit 14 --upper-limit 20 \
DEF:temp=$RRDPATH/DS1820.rrd:temp:AVERAGE \
CDEF:trend=temp,7200,TREND \
VDEF:tempmax=temp,MAXIMUM \
VDEF:tempaverage=temp,AVERAGE \
VDEF:tempmin=temp,MINIMUM \
LINE1:temp$RAWCOLOUR:"stuendlich" \
LINE1:trend$TRENDCOLOUR:"2h Mittelwert" \
COMMENT:"\n" \
COMMENT:"Maximum " \
COMMENT:"Average " \
COMMENT:"Minimum\n" \
GPRINT:tempmax:"%2.1lf%s°C" \
GPRINT:tempaverage:"%2.1lf%s°C" \
GPRINT:tempmin:"%6.1lf%s°C"
#day
rrdtool graph $OUTPATH/day.png --start -1d --alt-autoscale --lower-limit=14 --upper-limit=20 \
DEF:temp=$RRDPATH/DS1820.rrd:temp:AVERAGE \
CDEF:trend=temp,21600,TREND \
VDEF:tempmax=temp,MAXIMUM \
VDEF:tempaverage=temp,AVERAGE \
VDEF:tempmin=temp,MINIMUM \
LINE1:temp$RAWCOLOUR:"taeglich" \
LINE1:trend$TRENDCOLOUR:"6h Mittelwert" \
COMMENT:"\n" \
COMMENT:"Maximum " \
COMMENT:"Average " \
COMMENT:"Minimum\n" \
GPRINT:tempmax:"%2.1lf%s°C" \
GPRINT:tempaverage:"%2.1lf%s°C" \
GPRINT:tempmin:"%6.1lf%s°C"
#day_big
rrdtool graph $OUTPATH/day_big.png --start -1d --alt-autoscale --width 1024 --height 256 --lower-limit=14 --upper-limit=20 \
DEF:temp=$RRDPATH/DS1820.rrd:temp:AVERAGE \
CDEF:trend=temp,21600,TREND \
VDEF:tempmax=temp,MAXIMUM \
VDEF:tempaverage=temp,AVERAGE \
VDEF:tempmin=temp,MINIMUM \
LINE1:temp$RAWCOLOUR:"taeglich" \
LINE1:trend$TRENDCOLOUR:"6h Mittelwert" \
COMMENT:"\n" \
COMMENT:"Maximum " \
COMMENT:"Average " \
COMMENT:"Minimum\n" \
GPRINT:tempmax:"%2.1lf%s°C" \
GPRINT:tempaverage:"%2.1lf%s°C" \
GPRINT:tempmin:"%6.1lf%s°C"
#week
rrdtool graph $OUTPATH/week.png --start -1w --alt-autoscale --lower-limit=14 --upper-limit=20 \
DEF:temp=$RRDPATH/DS1820.rrd:temp:AVERAGE \
VDEF:tempmax=temp,MAXIMUM \
VDEF:tempaverage=temp,AVERAGE \
VDEF:tempmin=temp,MINIMUM \
LINE1:temp$RAWCOLOUR:"woechentlich" \
COMMENT:"\n" \
COMMENT:"Maximum " \
COMMENT:"Average " \
COMMENT:"Minimum\n" \
GPRINT:tempmax:"%2.1lf%s°C" \
GPRINT:tempaverage:"%2.1lf%s°C" \
GPRINT:tempmin:"%6.1lf%s°C"
#week_big
rrdtool graph $OUTPATH/week_big.png --start -1w --alt-autoscale --width 1024 --height 256 --lower-limit=14 --upper-limit=20 \
DEF:temp=$RRDPATH/DS1820.rrd:temp:AVERAGE \
VDEF:tempmax=temp,MAXIMUM \
VDEF:tempaverage=temp,AVERAGE \
VDEF:tempmin=temp,MINIMUM \
LINE1:temp$RAWCOLOUR:"woechentlich" \
COMMENT:"\n" \
COMMENT:"Maximum " \
COMMENT:"Average " \
COMMENT:"Minimum\n" \
GPRINT:tempmax:"%2.1lf%s°C" \
GPRINT:tempaverage:"%2.1lf%s°C" \
GPRINT:tempmin:"%6.1lf%s°C"
#month
rrdtool graph $OUTPATH/month.png --start -2592000 --alt-autoscale --lower-limit=14 --upper-limit=20 \
DEF:temp=$RRDPATH/DS1820.rrd:temp:AVERAGE \
VDEF:tempmax=temp,MAXIMUM \
VDEF:tempaverage=temp,AVERAGE \
VDEF:tempmin=temp,MINIMUM \
LINE1:temp$RAWCOLOUR:"monatlich" \
COMMENT:"\n" \
COMMENT:"Maximum " \
COMMENT:"Average " \
COMMENT:"Minimum\n" \
GPRINT:tempmax:"%2.1lf%s°C" \
GPRINT:tempaverage:"%2.1lf%s°C" \
GPRINT:tempmin:"%6.1lf%s°C"
#month_big
rrdtool graph $OUTPATH/month_big.png --start -2592000 --alt-autoscale --width 1024 --height 256 --lower-limit=14 --upper-limit=20 \
DEF:temp=$RRDPATH/DS1820.rrd:temp:AVERAGE \
VDEF:tempmax=temp,MAXIMUM \
VDEF:tempaverage=temp,AVERAGE \
VDEF:tempmin=temp,MINIMUM \
LINE1:temp$RAWCOLOUR:"monatlich" \
COMMENT:"\n" \
COMMENT:"Maximum " \
COMMENT:"Average " \
COMMENT:"Minimum\n" \
GPRINT:tempmax:"%2.1lf%s°C" \
GPRINT:tempaverage:"%2.1lf%s°C" \
GPRINT:tempmin:"%6.1lf%s°C"
#year
rrdtool graph $OUTPATH/year.png --start -1y --alt-autoscale --lower-limit=14 --upper-limit=20 \
DEF:temp=$RRDPATH/DS1820.rrd:temp:AVERAGE \
VDEF:tempmax=temp,MAXIMUM \
VDEF:tempaverage=temp,AVERAGE \
VDEF:tempmin=temp,MINIMUM \
LINE1:temp$RAWCOLOUR:"jaehrlich" \
COMMENT:"\n" \
COMMENT:"Maximum " \
COMMENT:"Average " \
COMMENT:"Minimum\n" \
GPRINT:tempmax:"%2.1lf%s°C" \
GPRINT:tempaverage:"%2.1lf%s°C" \
GPRINT:tempmin:"%6.1lf%s°C"
#year_big
rrdtool graph $OUTPATH/year_big.png --start -1y --alt-autoscale --width 1024 --height 256 --lower-limit=14 --upper-limit=20 \
DEF:temp=$RRDPATH/DS1820.rrd:temp:AVERAGE \
VDEF:tempmax=temp,MAXIMUM \
VDEF:tempaverage=temp,AVERAGE \
VDEF:tempmin=temp,MINIMUM \
LINE1:temp$RAWCOLOUR:"jaehrlich" \
COMMENT:"\n" \
COMMENT:"Maximum " \
COMMENT:"Average " \
COMMENT:"Minimum\n" \
GPRINT:tempmax:"%2.1lf%s°C" \
GPRINT:tempaverage:"%2.1lf%s°C" \
GPRINT:tempmin:"%6.1lf%s°C"
Alles anzeigen