"Joey's Room Engine" is my project to automate and control my bedroom using electronic and computer components. So far, my Main ceiling light, bedside light and fan is controlled. I have plans to get my window blinds motorised. The system currently features the following:
Speech recognition
iPhone/iPod Touch control via an iPhone Web App
Control from a Windows client application
Multithreaded TCP/IP server
Non-computer mode, the Microcontroller can work independently with switches
The system is broken down into the following modules:
Room Engine TCP/IP Server (REServ)
REServ is a multithreaded TCP/IP server written in Microsoft Visual Basic 6. It's purpose in life is to process requests from clients, and subsequently relay instructions to the Microcontroller (REBoard) over the serial (RS232) port. It features password authentication, to stop unauthorised clients being able to control the room. Calls avaliable to clients include the ability to send an output byte to the REBoard, getting the status of each individual appliance (on or off), getting the firmware version of the REBoard, and the version of the server. Although it may not seem necessary to have a server program, it became apparent it was needed when I had multiple clients, which had routine for directly accessing the REBoard over the serial port. If multiple clients tried to do something at the same time, port conflicts would occur and everything would fail. Also, if extensions or updates are made to the communication routines (between the computer and REBoard), then the changes only have to be made on the REBoard and REServ, and not every client.
Microcontroller (REBoard)
The Microcontroller is an Atmel AVR ATMEGA8515 situated on an Atmel STK500 development board, which incorporates a MAX232 and other components. It's purpose is to process instructions from the computer, and deal with them accordingly (when in Serial mode). The firmware that I have written also includes 'manual mode', which allows the room to function as normal without a computer (with light switches, etc). This is selectable by pushing a button on the board. Three LEDs are wired up, which indicate whether the REBoard is in manual or serial mode, and whether a serial session with REServ is operational. The firmware is written in C, using AVR GCC. There are 4 presets also hard coded into the firmware, which can be triggered from REServ.
I have also wired in some push to make switches by my bedside which allow control of the three appliances. The outputs from the Microcontroller are amplified through a ULN2004 Darlington array, which are then fed to the corresponding relay switch (with a protection diode). Here is the modification carried out to my main ceiling light:
Speech Recognition Client
This application is also written in Visual Basic 6, and uses the Microsoft Speech SDK, and the Winsock control for communication with the server. In short, it picks up pre-defined keywords or 'buzzwords' via a microphone for each appliance, and either turns it on or off. Even though it sounds complicated, it is made easy thanks to the Speech SDK. I have plans to port this to C#.NET for my A-Level Computing project.
iPhone Web App Client
This is in my opinion the best client out of the three. It is a bunch of PHP scripts running on Apache. Each page is styled to the iPhone chrome using iWebKit to give the appearance of a proper iPhone application. This also leverages PHP's socket capabilities to talk to REServ. The authentication is not done in the PHP scripts, but instead the PHP scripts talk to the REServ to verify the credentials. Session cookies are used to store the password, if it was verified, as a persistent connection cannot be made across multiple pages, so each script has to authenticate each time it needs to talk to REServ.
Windows .NET Client
Not really much to say about this one, apart from that it's written in VB.NET. It just features a simple form with checkboxes, and uses .NET's socket libraries to communicate with REServ
Video
The Old System
Before I had this fancy client-server based system in place, it all just used to run from a VB6 app, which connected straight to the Atmel board. I plan to re-write this application when I have time, so that it chats to the server instead, as it provided a nice way to control the room: Virtual View.
Above: Virtual View open. Virtual View could be opened from the main window from the tools menu.
Above: Click the appliance you want to turn on/off, and it does just that, on the screen and in real life!
Source code, Specifications and Binaries
I really wish I could go much further into the nitty gritty of how this all works, including source code, and communication routines, but as I am using this project for my A-Level Computing project, I cannot afford for my work to be plagarised, then being involved in a dispute for plagarism. I will most likely release all of this when I have completed it, but for the time being, I would rather not release anything.
Future Plans
As I will be doing this as a piece of coursework, I am going to do the following:
Rewrite the entire system, making it object orientated where possible, and making the source very neat
Try and make the firmware interrupt driven, instead of polling registers
Implement scheduling (i.e. Turn on this light at 6PM)
Improve the iPod Touch web app to incorporate the scheduling control
Improve security a bit (but not over the top)
Page Comments
Please visit the Forum. Here you may find more information related to the page you are on, and you too can contribute. Sign up now! It won't take a minute