I have (finally) got my project to a working stage so I thought I’d write a bit about it. After buying a CurrentCost CC128 device I was not happy with the software on the Internet for extracting the data. The FDI chip used on the USB cable to the device did not support 64 bit Windows 7 so it crashed on me and the Linux alternatives were basic and look fairly complicated to set up.
I have not decided what technology for the server side script which would handle the AJAX requests but I ended up using PHP. The PHP script retrieves data from the database, formats it and sends it back to the web page to be graphed.
I have a LAMP stack configuration so I’m using an Apache web server with a MySQL database. All the device data will be stored in the database by a another script which I wanted to use Python for.
The Python script listened for the XML strings sent via a USB cable from the CurrentCost device. The script would then extract the data from XML and store it into the database.
From the start I wanted my software to run on a Linux based system because I want a server at home running on Linux 24/7. This would allow my other devices to be freely turn it self off etc. Also most of other services were on Linux.
The FDI chip from the USB cable takes care of the USB to Serial conversion which makes reading data a lot easier but also it uses an up to date connection. Using a terminal and example XML documents found on the web I could see what the XML format looks like. All data is sent every 6 seconds over USB to a serial port. Ever 1 minutes past the hour e.g 15:01 historical data is sent over the cable or by pressing a button on the device.
Once received the Python script parses the XML, extracts data it needs and inserts it into the database.
At the moment there are loads of problems and improvements that can be done. This is just a brief post of what I have so far. The Python script can’t handle the historical data and falls over so it won’t run longer than 1 hour.
The AJAX response returns a formatted string. I want to convert this to an XML response so it’s easier / cleaner to retrieve multiple data.
I want to limit the data by date / time because the graph will look tiny / there would be a lot of information being sent back and forth every 10 seconds refresh.
I’m not happy with the scaling of the graphs. It’s using dual axis for energy and temperature.
Some sort of statistics besides a graph like total engery consumed for x days/months/years, etc.
Eventually the Python script will become a Linux Daemon but this is only once it’s stable enough.
Twitter Integration would be nice. I would use the Python script to post a tweet every hour with a simple message. The profile will be protected so that only I can see what it says.
Still got ways to go but it’s getting there. It’s nice to finally see something from my days of work. Especially if I have never used Python or PHP from scratch before.