All of the interesting technological, artistic or just plain fun subjects I'd investigate if I had an infinite number of lifetimes. In other words, a dumping ground...
Wednesday, 23 September 2009
Wednesday, 16 September 2009
Bobby Tables
Python
Using the Python DB API, don't do this:
cmd = 'update people set name='%s' where id='%s'%(name, id)
curs.execute(cmd)
instead, do this:
curs.execute('update people set name=:1 where id=:2', [name, id])
http://bobby-tables.com/
Wednesday, 9 September 2009
Open energy monitor
From http://lwn.net/Articles/349007/
The OpenEnergyMonitor project
The OpenEnergyMonitor project is based on the work of two developers, Trystan Lea and Suneil, both from Wales. "This is a project to develop and build open source energy monitoring and analysis tools for energy efficiency and distributed renewable microgeneration." The project appears to have been launched in the summer of 2009.
The OpenEnergyMonitor project's graphic [PDF] describes the goals, which include:
- Monitoring AC mains for energy analysis purposes.
- Energy prediction for renewable energy feasibility studies (Planned).
- Monitoring energy captured from wind, solar water and photovoltaic sources.
- Storage, analysis and display of energy usage data.
- Development of energy technologies.
- The export of energy usage information to the Internet (Planned).
The OpenEnergyMonitor site lists several example projects:
- Non-invasive AC mains current measurement
- Invasive AC mains power measurement
- Invasive 12V DC power measurement
- load controller for small wind generators
OpenEnergyMonitor features a simple structure that is built from a variety of open-source hardware and software components. The data flow through the system starts with an Arduino processor and a custom built I/O shield for interfacing the analog signal to the Arduino. The Arduino sends data to the host computer via a USB serial connection.
The project provides several ways to collect and display the power data. The simpler batch mode works as follows: The ArduinoComm Java program can be used to copy a batch of recorded data to a file using a command such as:
$ java ArduinoComm >tmp.datGraphing of the captured data can be done with the KDE utility kst, see the Using KST for graphing document for details.
A more interactive real time display can be achived using the PowerLogger and PowerSampler Java programs. A test installation of both programs was performed on an Ubuntu 9.04 system. The OpenEnergyMonitor java software guide was followed. Each program requires installation of the associated Arduino program (sketch) on the Arduino board. Your author had several Arduino Deicimila boards around from other projects and an already installed version 17 of the Arduino IDE. The Arduino Power Logger program (sketch) was retrieved, compiled and installed on the Deicimila board without any problems.
Next, Java was installed on the machine along with the RXTX serial/parallel communication library. The Java code was compiled and run with the java ContinuousPower command. The ContinuousPower GUI showed up and after clicking on the Start button, the Arduino status indicated that a connection was established and an a flow of data was seen from the Arduino board. The real time graph's X axis changed with advancing time and the data changed slightly due to noise. Unfortunately, your author did not have the parts on hand to construct an input shield board, so monitoring of some real data was not possible. The PowerSampler program was compiled and installed with similar results.
For more information on the inner workings of the Java software, see the Power Logger Source Code Guide and the Program Structure and Data Flow Diagram. The latter explains both the Power Logger and Power Sampler Java programs since both share a large percentage of source code.
OpenEnergyMonitor is an interesting project in the early stages of development. It comes along at a time when the renewable energy field is seeing a lot of growth, and efficiency monitoring of non-renewable sources is becoming more important for both financial and ecological reasons. Hopefully, future releases of OpenEnergyMonitor will include a wider variety of supported sensor devices. A multi-channel temperature monitor would be useful for characterizing a variety of solar energy sources such as photovoltaic, hydronic (hot water) and solar-heated air panels.
The OpenEnergyMonitor project could also be useful for providing a base of working code for a more generic Arduino-based data logger, and the real-time data visualization capabilities are an added bonus. A thread on the Arduino forum about an Open Source Data Logger Project Using the Arduino indicates some potential interest, but that project apparently never got off the ground.