# The Owl USB Energy Meter and using the SQLite Database with PHP

14 Jun

I’ve had The Owl running for a little while now and the software that comes with it is a little bit rubbish to be honest. I kinda works OK I guess but is very limited, so it was time to have a little hack at it and see what I could find.

I basically wanted to plug the Owl monitor into my server and then record all the data into a MySQL database that I could then query and display pretty charts using PHP. I tried a few 3rd party bits of software, but none of them worked, none of them would even connect to the Owl via USB, so that led me back to the original Owl software.

You can export data to a CSV using the GUI, but this is a manual process and I’m more interested in automation, as you may have guessed. So, after a bit of digging, it seems that the Owl software saves data once a minute to a .db file which can be found in C:\ProgramData\2SE\be.db

This file can be opened with SQLite Database Browser 2.0, it’s pretty straight forward if you have a little nose around.

After a bit of playing I finally figured out how to get the data I was after. ‘ch1_kw_avg’ * 0.060 = Average kWh for that minute.

Try this query for example:

select ch1_kw_avg*0.060 as 'Live kWh' from energy_history
order by dt desc
limit 1

This will return the most recent kWh data, near enough your live kWh, the same figure that should be displayed on your Owl monitor.

So, after installing PHP on one of my servers I then setup a basic website (having used this code as a base) which would talk to the database and return the information I wanted. It also auto refreshes every 60 seconds. This is still in it’s very early stages, but I plan to make this app quite powerful with graphs and fancy stuff!

# Dave’s Energy Page

query("select ch1_kw_avg*0.060 as 'Live kWh' from energy_history
order by dt desc
limit 1
");
$currentkwh =$result->fetch();

$dsn = null;$output  =  'Current Usage: '.number_format((float)$currentkwh['Live kWh'], 3, '.', '') . " kWh"; echo ' # ‘.$output.’

';

} catch(PDOException $e) { echo$e->getMessage(); }

?>

This of course requires the Owl Energy Usage Monitor software to be running 24/7 and recording all the data in the SQLite DB. this shouldn’t be a problem for me as my servers are always online. With a quick NAT I can now access this page from anywhere, which will be handy once I’ve made a fancy app from it.

For reference, some official documentation can be found here.