Young Scientist ‘09
After my experience in last years Young Scientist Exhibition I decided that I would definitely try and enter again this year. After a lot of thought I decided upon my project entitled ‘Energy Saving through Automation’. In a nutshell I created an automation system for controlling household appliances and domestic lighting to combat standby power wasting.
Fortunately my project won two prizes, being 1st in Intermediate Technology Individual and the Science Foundation of Ireland special award which is given for research/engineering in the field of energy conservation technology.
The electronics part of the project was created using the Arduino micro-controller platform. For those that don’t know what the Arduino is, its a prototyping electronics platform created for hobbyists, by hobbyists. The Arduino provided the perfect platform on which to start working with electronics. The board itself runs its own variant of C/C++ and the support forums and language reference are to say the least, second to none.
The Arduino also provides easy communication through its serial interface. Implementing serial communication between my MacBook and the board proved to be a very simple affair, instead of being the difficult task I expected it to be. Things such as receiving strings through the serial interface provide the programmer with nice little challenges which I found did a lot for bringing me back to thinking in C.
char string[16]; void setup(){ Serial.begin(9600) // Start the serial port with a baud rate of 9600 } void loop(){ if (Serial.available() > 0){ // If there is a character to be read int i = 0; // Start a counter while (Serial.available() > 0){ string[i] = Serial.read(); // Append the character to create a string i += 1; // Increment the counter } } }
Serial communication on the MacBook end also proved to be easier than I first thought. Using the pySerial module for Python made serial communication with the board a breeze.
def read(self): import serial # Import the pySerial module s = serial.Serial("/dev/tty.usbserial-A9005fkd", 9600) # Start the serial interface with a baud rate of 9600 message = s.readline() # Read a line from the serial interface return message # Return that line
I decided to use Python to write the “handler” that controlled the Arduino for many reasons. The handler application controlled all communication between components allowing for things such as the web interface (see below) to control the Arduino remotely. The main reason I chose Python is that it has ease of use in abundance. Python comes with native support for the SQLite database platform which I used to store information for a web interface in my project. Python also promotes good coding practices with things such as tab indentation (which every good programmer should use anyway) being required to nestle code under things such as if statements or while loops. This inherently breaks the code up into easily readable blocks making scripts a lot easier to read.
I decided that to keep things simple that I would write a web interface using Python as well for my project. There were many choices for web frameworks for Python but I eventually settled on the Django framework as it was the one recommended to me by friends. Django made developing the web interface quite easy with things such as limiting access to views to authenticated users becoming a one-line addition to the code. I found this a very pleasant change from using PHP and the CodeIgniter framework where such things would have to be written from scratch when starting a new project. It would make me seriously consider using Django for future development instead of PHP and CodeIgniter (although I do hear wonders about Ruby on Rails as well).
I hope to post more specifications on my project in the future but for reasons I can’t do it at the moment.
Enjoy,
Patrick

Congrats again mate!