###### create_astrowetter.sh ####### #!/bin/bash rrdtool create /srv/scripts/tinker/astrowetter.rrd \ --step 300 \ DS:t_sky:GAUGE:650:-80:100 \ DS:t_ambient:GAUGE:650:-50:100 \ DS:t_delta:GAUGE:650:-50:200 \ DS:light:GAUGE:650:0:65535 \ DS:humidity:GAUGE:650:0:100 \ RRA:AVERAGE:0.5:1:130000 \ RRA:MIN:0.5:60:720 \ RRA:MAX:0.5:60:720 ###### astrowetter.php ######## addDevice($tir); // Add device to IP connection // Don't use device before it is added to a connection // Get current object and ambient temperatures (unit is ÁC/10) $obj = $tir->getObjectTemperature() / 10.0; $amb = $tir->getAmbientTemperature() / 10.0; # Ende Auslesen des IR-Bricklet # Beginn Auslesen des Ambibient Light Bricklet $uid = '8Ss'; // Change to your UID $ipcon = new IPConnection($host, $port); // Create IP connection to brickd $al = new BrickletAmbientLight($uid); // Create device object $ipcon->addDevice($al); // Add device to IP connection // Don't use device before it is added to a connection // Get current illuminance (unit is Lux/10) $illuminance = $al->getIlluminance() / 10.0; # Ende Auslesen des Ambient-Light Bricklets # Beginn der Auswertung # ===================== $deltat = $obj - $amb; setlocale ( 'LC_TIME', 'de_DE' ); date_default_timezone_set('CET'); $zeit = date("d.m.Y - H:i T"); #echo "Messpunkt: $zeit\n"; #echo "Himmelstemperatur: $obj C\n"; #echo "Umgebungstemperature: $amb C\n"; #echo "delta T: $deltat C\n"; #echo "Beleuchtung: $illuminance Lux\n"; #echo "\n\n"; # Aufbau des Update-Strings fuer die RRD $RRDString = "/usr/bin/rrdtool update $RRDB N:$obj:$amb:$deltat:$illuminance:U \n"; # RRD als Shell-Befehl updaten $command = "$RRDString\n "; $output = shell_exec($command); echo "$output \n"; #echo "$RRDString\n"; # Grafik generieren $GGen = "/usr/bin/rrdtool graph /srv/scripts/astrowetter/astrowetter.png -s -1d -e +1h -w 600 -h 400 --vertical-label \"C\""; $GGen = "$GGen DEF:CLOUD=/srv/scripts/astrowetter/astrowetter.rrd:t_delta:AVERAGE LINE2:CLOUD#009900:\"Delta T\""; $GGen = "$GGen DEF:SKY=/srv/scripts/astrowetter/astrowetter.rrd:t_sky:AVERAGE LINE2:SKY#ff0000:\"Himmel (IR Messung)\""; $GGen = "$GGen DEF:AMBIENT=/srv/scripts/astrowetter/astrowetter.rrd:t_ambient:AVERAGE LINE2:AMBIENT#0000ff:\"Umgebung\""; $GGen = "$GGen \n"; $output = shell_exec($GGen); echo "$output \n"; #$command = "echo $zeit, $obj, $amb, $deltat >> /srv/scripts/astrowetter/skylog.txt"; #$output = shell_exec($command); #echo "$output \n"; $ipcon->destroy(); ?> ########## Auslesen der RRDB von der Kommandozeile ######### rrdtool fetch astrowetter.rrd AVERAGE -r 300 -s -1h t_sky t_ambient t_delta light humidity 1343906700: 2,0193501433e+01 2,8998700287e+01 -8,8051988533e+00 8,6738700287e+02 -nan 1343907000: 1,9503004948e+01 2,9199141443e+01 -9,6961364950e+00 8,6919227299e+02 -nan 1343907300: 2,0890644225e+01 2,9398663461e+01 -8,5080192360e+00 8,6810735097e+02 -nan 1343907600: 2,1794899409e+01 2,9400000000e+01 -7,6051005910e+00 8,6710566732e+02 -nan 1343907900: 2,2297787795e+01 2,9200884882e+01 -6,9030970870e+00 7,9760882382e+02 -nan 1343908200: -nan -nan -nan -nan -nan 1343908500: -nan -nan -nan -nan -nan 1343908800: -nan -nan -nan -nan -nan 1343909100: -nan -nan -nan -nan -nan 1343909400: 1,8990025381e+01 2,2987925462e+01 -3,9979000803e+00 4,8884323231e+02 -nan 1343909700: 1,8900617471e+01 2,2403704826e+01 -3,5030873550e+00 8,6148633616e+02 -nan 1343910000: 1,8402906802e+01 2,2598837279e+01 -4,1959304777e+00 8,6688197783e+02 -nan 1343910300: -nan -nan -nan -nan -nan