pagetop
Steve’s Home Page
Steve’s blog on the web

Rutherglen – Easter 2011

May 1st, 2011 by Steve

Begonia and I spent the extra-long Easter weekend in 2011 in Rutherglen enjoying wine, cheese and geocaches.

IMG_3781

We stayed at The Cottage on the Murray which provided a lovely base to explore the surrounding region. We visited a few of the local wineries on the first day before exploring further afield. The weather was perfect with clear warm autumn days and nights cool and crisp enough to fire up the slow combustion stove.



 

Eversolar Inverter Monitoring with Linux

December 19th, 2010 by Steve

In November 2010 I have a 1.5kw solar power system installed by Nu Energy. It came with an Eversolar TL2000AS inverter and since it came with an RS-232 & RS-485 interface I figured it wouldn’t be too hard to monitor & graph it on my web server.

I fired off an email to Nu Energy asking for software to do this but they referred me to Eversolar so I contacted them directly. Unfortunately it seems that the RS-232 interface is only used for uploading firmware, despite what the manual says. They gave me two options – purchase their Power Management Unit (PMU) or one from a German company Solar Log. I went with the former (US$300 vs US$1000).

The Eversolar PMU connects to the inverter via RS-485 using a straight-through RJ-45 cable and is connected to my LAN via ethernet. It can also be connected directly to a PC via USB and comes with some Windows software called AS Control. Since I wanted to monitor it from Linux I was hoping that it would support SNMP, but alas, that wasn’t the case.

The AS Control software communicates with the PMU via HTTP on port 8080. I used WireShark to look at the communication and implemented enough to be able to pull what I needed from the PMU with a Perl script and graph it with MRTG & RRDtool. You can see the graphed results in my Power Stats page.

One thing I discovered about the PMU is that it will actually run on power from the Inverter via the RS-485 connection so you don’t actually need the external power pack. The downside of this is that it it only works when the Inverter is providing power but I can live with this.

I’d be interested in hearing from anyone who’s doing something similar with Linux or has any information on the communication protocol for the Eversolar PMU.


DownloadDescriptionVersionUploaded
pmulogger.zipEversolar PMU/Inverter perl data logger0.1b20-12-2010



 

Weather Station data logger

March 23rd, 2010 by Steve

I recently bought a wireless Weather Station on eBay and wanted to hook it up to my web server which runs Linux.

Wireless Weather Station

Google revealed a couple of free software options (one in C, the other in Python) and a couple of useful sites, in particular Jim Easterbrook’s and Michael Pendec’s.

The Python package was overkill for my needs and I was initially planning to modify the C source but it was a bit, er, messy so I decided work on my Perl skills and write something from scratch.

You can see the graphed results in my Environmental Stats page.


DownloadDescriptionVersionUploaded
wslogger.plWeather Station data logger written in perl1.312-02-2011



 

Nagios check plugin for MythTV

July 18th, 2008 by Steve

Nagios is an Open Source host, service and network monitoring application that I use to monitor a couple of servers I have at home as well as a couple out on the Internet that I look after. One of my home servers is a Home Theatre PC running Linux and MythTV, and while Nagios checks to make sure its up and monitors its disk space, load & temperature, I wanted to check MythTV itself so I wrote a check plugin to do just that.

The check_mythtv plugin connects to the mythbackend process to make sure its running. It reports the status of the tuners and checks to see how much program guide is available:

$ ./check_mythtv.pl -H mythpvr
Ok: Tuners idle, 7 days program guide available

Normally I have around 7 days worth of guide data so I set the plugin to generate a warning alert (via email) if it falls to 4 days and a critical alert at 2 days. The plugin is a simple Perl script so it could easily be modified to check other things.


DownloadDescriptionVersionUploaded
check_mythtv.plNagios plugin for MythTV1.112-02-2011



 

Cook Islands Holiday

April 20th, 2008 by Steve

In April 2008 Begonia and I enjoyed our first overseas holiday together in the Cook Islands.

Cook Islands - April 2008

We left Sydney on Sunday 6th April and flew to the main Island of Rarotonga where we spent three days at the Rarotongan Beach Resort. It was very nice , but was only a taste of what was to come. We spent our first day relaxing at the resort – some snorkeling, the odd cocktail etc. The next day we headed into the main town of Avarua for a bit of a look around and some Black Pearl shopping. On our last day we headed over to Muri beach to do the Geocache on the Island and then a swim at a nearby beach.

We then flew over to the Island of Aitutaki and spent three days at the Aitutaki Lagoon Resort where we discovered paradise. The resort is actually on it’s own private Island called Akitua which is reached by a ferry. There were only about 40 guests at the resort while we were there, and coupled with the perfect weather it was an amazing relaxing few days.

On the first evening we went on a sunset cruise with one other couple before enjoying a five course dinner. On the second night we had an Umu (like a New Zealand Hāngi) feast following by some traditional dancing. One our last day we went on a cruise of the Lagoon which included a snorkeling stop and a BBQ lunch on One Foot Island we found another geocache.

Before coming home we spent three days in Auckland where we did some sight seeing, shopping and caching. After a week of lovely warm sunny weather in the Cook Islands Auckland turned on some typical wet weather which helped prepare us for the cold, wet autumn weather we were to get when we got home.

You can check out some photos from the trip in my Gallery



 

Reducing the AC3 bitrate of a video file

January 31st, 2008 by Steve

I recently tried unsuccessfully to watch an HD movie on my MythTV box, and while the video was fine the audio (Dolby Digital) kept dropping out. The CPU load on my server was pretty low so this wasn’t the problem and I tried copying the file to the server itself rather than accessing it via NFS from my file server to rule out network bandwidth problems.

I then decided that maybe my Amp couldn’t handle the high AC3 bitrate (640kbps) of this file so I looked into how I could reduce it. After much googling and experimenting I finally managed to create a version of the file with a reduced AC3 bitrate, and thankfully, it played fine. As it turned out the movie was pretty crap, but you get that sometimes.

I put together this script that uses various freely available Linux tools to split the video file into separate audio and video components, re-encodes the audio and then puts it back together in case I need to do this again in the future.


#!/bin/sh

infile=$1
outfile=$1-out

cd /media/Temp

tcprobe -i $infile

echo
echo Extracting AC3 soundtrack ...
echo

tcextract -d2 -i $infile -a0 -x ac3 | tcextract -d2 -x ac3 -t raw > soundtrack.ac3

echo
echo Extracting individual audio channels ...
echo

export AC3_6CH=en
/share/bin/ac3dec -o null soundtrack.ac3

echo
echo Converting individual audio files to WAV ...
echo

for i in *.pcm
do
echo $i
sox -t raw -r 48000 -w -s $i `basename $i .pcm`.wav
done

echo
echo Recreating AC3 soundtrack ...
echo

rm -f 6ch.ac3
multimux -f en_l.wav en_c.wav en_r.wav en_ls.wav en_rs.wav en_lfe.wav

echo
echo Creating Xvid AVI file ...
echo

transcode -i $infile -p 6ch.ac3 -y xvid -e 48000,16,6 -E 48000,16,6 -A -N 0x2000 -o $outfile

rm -f *.pcm *.wav

The hardest part was extracting the individual audio tracks from AC3 and I eventually found this site which had a patched version of an AC3 decoder. I had to do a bit of work to get it to compile on a recent Linux system.



 

The Log Cabin

June 19th, 2007 by Steve
Log Cabin front

On the June long weekend in 2007 Begonia and I headed to Medlow Bath in the Blue Mountains where we stayed at the delightful Log Cabin.

Unfortunately, the weather wasn’t delightful, at least on the Friday & Saturday with strong winds and heavy rain which flooded the cellar of the cabin taking out the central heating and hot water system. Fortunately the owner pumped it out on the Saturday and managed to get the hot water system going and there was plenty of wood to keep the fire going.

We spent Saturday morning shopping in Katoomba and then had high tea at the Hydro Majestic. On Sunday the weather had improved enough to go for a bit of a walk so we went and found two nearby geocaches. After this exercise we had a spa and a nap before heading to Ashcrofts in nearby Blackheath for dinner.



 

Steve’s Burritos

May 17th, 2007 by Steve

This is my Girlfriend’s favourite recipe.

Ingredients (serves 2 hungry Amigos):

    4-6 Tortillas (depending on size)
    1 Jar (375gm) of Old El Paso Thick ‘n Chunky Salsa (Medium)
    1 Chorizo – quartered length ways then chopped
    1 Small onion – chopped
    1 Capsicum – chopped
    A couple of mushrooms – chopped
    1 cup of cherry tomatoes cut in half
    1 cup of Kalamata olives
    140g Tomato paste
    1 Can Mexican chilli beans
    1 Clove of garlic – finely chopped
    1 Small chilli – finely chopped (Optional)
    300g grated low-fat Mozarella
    Paprika
  1. Fry chorizo over a medium heat for 2-3 minutes
  2. Add garlic and optional chilli and fry for 1-2 minutes
  3. Add onion, capsicum & cherry tomatoes and fry for 2-3 minutes
  4. Stir in salsa, beans, tomatoe paste, mushrooms and olives
  5. Bring to the boil and simmer for about 10 minutes
  6. Preheat oven to 180 degrees and give an oven proof dish a light spray of oil
  7. Spoon the mixture into the tortillas and place them in the dish
  8. Cover burritos with the cheese and sprinkle paprika over them
  9. Bake for about 10 minutes

Any left-over filling can be frozen.



 

Rainwater tank level monitoring with Linux

April 24th, 2007 by Steve

I’ve had a rainwater tank for a couple of years and because it’s located beside my garage where one of my Linux servers is I’ve always thought it would be cool to be able to graph the water level and display it on a web page. I’ve looked into it a few times but couldn’t find anything that would measure the water level and interface to a PC for a reasonable price.

The Aquagauge

Early in 2007 I finally found what I was looking for – the Aquagauge made by an Australian company Electrosense Technologies.

The monitor itself transmits the water level and temperature to a receiver unit which has an LCD display and an RS232 output for interfacing to a computer. The company has Windows software but when I explained that I wanted to use it under Linux they said that they can program the receiver to output the data in the following plain ASCII format, which is pretty easy to parse:

a1248b0c205d

In this example 1248 converts to a depth of 124.8 cm, 0 is the sign bit for the temperature (0 = +,1 = -) and 205 is the temperature in the transmitter, i.e. 20.5 deg C.

The Aquagauge was pretty easy to install and my only concern was that because my rainwater tank sits beside my garage I was concerned that the transmitter and receiver would be too close (< 3m). As it turned out, it wasn't a problem.

Interfacing to a Linux box

I already use a couple of free packages for producing graphs on my web site; MRTG and RRDtool, so I wanted to make use of them for monitoring the water level and temperature. All that was needed was a couple of scripts to make it happen.

Scripts

The main script aqualogger.pl is a perl script which monitors the serial port for the periodic data reporting, parses it and saves the water level and temperature in a temporary file. It is started at boot time and runs as a daemon.

#!/usr/bin/perl

use Device::SerialPort qw( :P ARAM :STAT 0.07 );

my $MAXVAR = 20;        # Maximum data variation (%)

my $port=Device::SerialPort->new("/dev/ttyS0");
my $tmpfile = "/var/tmp/aqualogger";

$port->baudrate(2400);
$port->databits(8);
$port->parity("none");
$port->read_char_time(0);     # don't wait for each character
$port->read_const_time(1000); # 1 second per unfulfilled "read" call
$port->are_match("d");

# Main loop

while (1) {
        my $gotit = "";
        until ("" ne $gotit) {
                $gotit = $port->lookfor;       # poll until data ready
                sleep 1;                          # polling sample time
        }

        $gotit =~ /a(\d+)b\dc(\d+)/;
        $level = $1 / 10;
        $temp = $2 / 10;

        #print "Level: $level, Temp: $temp\n";

        # Sanity check the values - occasionally it spits out a way off value

        $previous_level = $level unless (defined $previous_level);
        $previous_temp = $temp unless (defined $previous_temp);

        $level_var = $level / $previous_level;
        $temp_var = $temp / $previous_temp;

        if (($level_var < (1 - $MAXVAR/100)) || ($level_var > (1 + $MAXVAR/100))) {
                #print "Skipping level of $level\n";
                next;
        }
        if (($temp_var < (1 - $MAXVAR/100)) || ($temp_var > (1 + $MAXVAR/100))) {
                #print "Skipping temp of $temp\n";
                next;
        }

        # Save water level and temperature

        open (fh, ">$tmpfile")
                or die ("Unable to open $tmpfile : $!");
        print (fh $level . "\n");
        print (fh $temp . "\n");
        close (fh);

        $previous_level = $level;
        $previous_temp = $temp;
}

The second script aquadata.sh is a simple shell scripts which reads the two values from the temporary file and prints them out in a format suitable for mrtg to read.

#!/bin/sh
LOGFILE=/var/tmp/aqualogger

level=`head -1 $LOGFILE`
temp=`tail -1 $LOGFILE`

echo $level
echo $temp
echo 0
echo "Aquaguage data"

Configering mrtg and rrdtool

This is an extract from my mrtg.cfg file:

WorkDir: /var/db/mrtg
Interval: 2
RunAsDaemon: Yes

Title[aquaguage]: Aquaguage
Target[aquaguage]: `/share/scripts/aquadata.sh`
Options[aquaguage]: gauge
LogFormat: rrdtool

I run mrtg as a daemon but it can also be run periodically as a cron job.

Finally, I run a shell script every 15 minutes to produce the graphs:

RRDTOOL=/usr/bin/rrdtool
OUTDIR=/var/www/html/images

$RRDTOOL graph $OUTDIR/outside-temp.png \
       -a PNG \
       -h 80 -w 300 \
       -s -1week \
       -u 30 \
       -l 0 \
       -Y \
       -E \
       -v "Deg C" \
       -t "Outside Temperature (Past Week)" \
        -x HOUR:6:DAY:1:DAY:1:86400:'%a' \
DEF:ts1=/var/db/mrtg/aquaguage.rrd:ds1:AVERAGE \
VDEF:now=ts1,LAST \
VDEF:min=ts1,MINIMUM \
VDEF:max=ts1,MAXIMUM \
LINE1:ts1#001FFF:"Temperature" \
COMMENT:"Now\:" \
GPRINT:now:"%3.1lf" \
COMMENT:"Min\:" \
GPRINT:min:"%3.1lf" \
COMMENT:"Max\:" \
GPRINT:max:"%3.1lf" > /dev/null

$RRDTOOL graph $OUTDIR/waterlevel.png \
       -a PNG \
       -h 80 -w 300 \
       -s -1week \
       -u 100 \
       -l 0 \
       --rigid \
       -Y \
       -E \
       -v "%" \
       -t "Rainwater Tank Level (Past Week)" \
        -x HOUR:6:DAY:1:DAY:1:86400:'%a' \
DEF:ds0=/var/db/mrtg/aquaguage.rrd:ds0:AVERAGE \
CDEF:ts1=ds0,130,/,100,* \
VDEF:now=ts1,LAST \
VDEF:min=ts1,MINIMUM \
VDEF:max=ts1,MAXIMUM \
AREA:ts1#001FFF:"Level" \
COMMENT:"Now\:" \
GPRINT:now:"%3.1lf" \
COMMENT:"Min\:" \
GPRINT:min:"%3.1lf" \
COMMENT:"Max\:" \
GPRINT:max:"%3.1lf" > /dev/null

Note the CDEF line – it converts the water level to a percentage. In my case the maximum depth of my tank is 130cm.

One of the nice things about using RRDtool is that you can produce multiple graphs for different time ranges (e.g. weekly, monthly, yearly) because all the data is stored in an RRD database.

The Results?

You can see the graphs produced in my Environmental Statistics page.

Download

All the scripts and config files files are available for downloading in this Aquagauge scripts zip file.



 

Steve’s Nachos

April 20th, 2007 by Steve

Until the other day my Girlfriend considered herself the Nacho master, but after I whipped this up I think the she’s ready to hand the title over…

Nachos:

    Large pack of plain corn chips
    1 Jar (375gm) of Old El Paso Thick ‘n Chunky Salsa (Medium)
    1 Chorizo – quartered length ways then chopped
    1 Small onion – chopped
    140g Tomato paste
    1 Can Mexican chilli beans
    1 Clove of garlic – finely chopped
    1 Small chilli – finely chopped (Optional)
    1/2 Tsp cumin
    Paprika
    250g grated cheese (Cheddar, Mozarella etc)

Guacamole:

    1 – 2 Avocados (depending on size)
    1 Ripe tomato chopped finely
    1 Spring onion
    1 Lime
    1 – 2 Tbsp chopped coriander
    Salt and Pepper to taste

First, make the sauce:

  1. Fry chorizo over a medium heat for 2-3 minutes
  2. Add cumin, chilli, onion and garlic and fry for 1-2 minutes
  3. Add tomato paste, salsa and beans and simmer for about 10 minutes

While the sauce is simmering away you can make the guacamole:

  1. Mash the two avocados in a bowl
  2. Mix in the juice from the lime
  3. Stir in the chopped tomato, onion and coriander
  4. Season with salt and pepper

To assemble the nachos:

  1. Preheat oven to 180 degrees
  2. Line the bottom of a baking pan or dish with a layer of corn chips
  3. Sprinkle over some grated cheese
  4. Spoon over some of the sauce
  5. Add another layer or two of corn chips, cheese and sauce – try to finish with cheese
  6. Sprinkle over with paprika
  7. Bake for 10-15 minutes

Serve with the guacamole on the side or on top.



 
spacer
Steve’s Home Page is powered by a Linux server running WordPress, among other things.