Posts Tagged ‘perl’

A daily CurrentCost “bill”

Wednesday, May 28th, 2008

As I’ve finally got my home server capturing the electric meter readings from the CurrentCost, I thought it’d be good to try doing something with it.

I want to start with something a bit different to graphs, because there’s already been a lot of cool work done in different graphing approaches.

As I wrote yesterday, I’ve got a MySQL database that is storing the watt reading from the electric meter captured once every six seconds.

I wondered whether it makes sense to try and turn these figures into a financial cost. It might be interesting (and useful as a behaviour-altering thing) if we could get a “bill” from the CurrentCost meter each day that told us how much we spent on electricity the last day.

+=============================================+
  Your CurrentCost bill for 2008-5-27

     Electricity usage   4.9802 units
      Cost ==           £0.4874

     Standing charge    £0.1582
   ---------------------------------------
     TOTAL COST FOR 2008-5-27 : £  0.65
+=============================================+

I’m not entirely sure of my maths here, but I thought it could be interesting to give it a try.

(more…)

Accessing MySQL from Perl on SlugOS

Tuesday, May 27th, 2008

I’ve written about my CurrentCost meter that I’m using to monitor my home electricity usage, and the small home server that I’ve set up to collect the data.

Yesterday, I decided to make a start on collecting the data. My plan was to copy what Nick had done and create a MySQL database to store the info, with a table to store a timestamp and the watt reading from the CurrentCost meter.

CREATE TABLE currentcostdl (  
    time TIMESTAMP DEFAULT CURRENT_TIMESTAMP,  
    power FLOAT NOT NULL,  
    primary key(time));

I started with Nick’s Python scripts, but didn’t get very far.

The server, a NSLU-2 (or “slug”) is running SlugOS.

The problem was that there is no python-mysqldb package in the SlugOS repositories. I did try downloading the source for it from sourceforge to build it myself, but struggled to get the dependencies I needed to make it – urllib in particular was a big pain.

I also tried the debian package but again dependencies on SlugOS got in the way.

So I gave up on that and decided to do it myself using Perl – Perl and MySQL had to be easier, right?

Erm… not so much 🙂

(more…)