ic: website ic:blog
  ic: website Home · Archives · Photo Gallery · ic: forum RSS logo - thanks to www.nineteenlabs.comWeb feed (RSS)  
The life and times of james Hart: his family, his music, life in Luton and his occasional escapes onto the internet.

« Debut and procession | Main | A (long overdue) day trip to Bexhill »

Sunday, 2 September 2012

Owl + USB energy monitor - how to get live data from it (techie)

We've had an Owl energy monitor for a while; we decided on the version with the USB interface, since it's possible to download thirty days worth of energy use, which can then be used to get a better idea of when we're using too much electricity... that's the theory, anyway!

I thought I might see if I could get live data off the device, using the USB cable and the software that came with it. I was delighted to find that the latest version of the software - although it only works with Windows - can run in the background, and updates a fairly simple SQLite database with the latest data from the Owl.

It's therefore possible to run queries against the database, using the SQLite3.exe command line (which is obtainable from the http://www.sqlite.org/download.html>sqlite.org website (at the time of publishing, it's in the sqlite-shell-win32-x86-3071300.zip file) to output the data:

C:\Uses\james> echo select * from energy_history; | sqlite3 C:\ProgramData\2SE\be.db

The data will rattle up the screen - it's up to you how you use this information, but the key bit is getting the information from the fields of the database; the separator is |.

The important fields are (save for fields 2 to 6, which contain individual date and time elements) 7 and 15, which contain an electrical current value and the full date. To get the current kW reading, though, one has to multiply the current value by 60 and then by the voltage supply as set in the options of the Owl (generally 240) then dividing by 1000. In this case, then:

1719928|2012|9|2|12|34|0.0385|8.855|46|1292|0.0385|0.0385|8.855|8.855|2012-09-02 12:34:00.000

The current power at 12:34 on the 2nd September is 0.0385 * 60 * 240 /1000 = 0.5544kW

How you express this depends on what you'd like to do with it; I've written a bit of shell script that uses gawk to extract the data then compiles it into an RSS file, and I use the Simple RSS Widget on my Android phone to display the most recent state of our electricity use. For completeness, here's the script:

#!/bin/bash
webroot="/var/html/"
rssfile=owl.rss
webrss=$webroot"/"$rssfile
pubdate=`date +"%a, %d %b %Y %H:%M:%S %z"`
nowdate=`date +"%H:%M:%S %d-%m-%y"`
guid=`date +%Y%m%d%S%M%H`
thisdata=`echo "select * from energy_history;" | /usr/bin/sqlite3 /media/owl/be.db | /usr/bin/tail -n 1`
thisused=`echo $thisdata | /usr/bin/gawk -F "|"  '{ avg = (int($7 * 60 * 240)) } END {print int(avg/10)/100} '`
thisdate=`echo $thisdata | /usr/bin/gawk -F "|"  'END {print substr($15, 1, 19)} '`
Owl energy monitor
echo '' > $webrss
echo '' >> $webrss
echo '' >> $webrss
echo '        Owl report' >> $webrss
echo '        Current status of Owl energy monitor' >> $webrss
echo '        http://www.your.site/'$rssfile'' >> $webrss
echo '        '$pubdate' ' >> $webrss
echo '        '$pubdate' ' >> $webrss
echo '        600' >> $webrss
echo '        ' >> $webrss
echo '                Owl update at '$thisdate'' >> $webrss
echo '                Current Owl display: '$thisused'kW' >> $webrss
echo '                '$guid'' >> $webrss
echo '                '$pubdate'' >> $webrss
echo '        ' >> $webrss
echo '' >> $webrss
echo '' >> $webrss

# do the test

Posted by james at September 2, 2012 12:02 PM


 
This site is owned and operated by Image Communications, including all content and stuff.
It's powered by Movable Type 5.2