Developing the ambient lighting system — what I’m actually working on

Leave a comment

So I shifted my priorities away from just a ‘boring’ sunrise lamp and am now working towards my very own vision of a powerful extensible ambient lighting system. The project has three major construction sites: a client application which lets the end-user control his light system; the RGB lamp hardware and its electronic circuitry; and last but not least, the server application which ties everything together and brings the smart into smart home. The required skills and knowledge for each of those aspects couldn’t be more different, and each poses its own unique challenges. This makes it a very demanding task but even more so an exciting one as well.

Scope of functionality

The big question I’m asking myself is “What is the light system supposed to accomplish?”. The basic set of features includes the possibility of changing the light colour and controlling individual as well as a group of lights separately. The next step encompasses functionality that allows for more dynamic behaviour. Implementation of a multitude of effects combined with timed and triggered events. The idea is to create basic colour transitions and events, which, combined and looped in different ways, create more complex effects. For example, a sunrise simulation or obligatory party modes with rainbow flashes and strobe lighting.

I have to admit, that I preferred to stay pretty vague with that, so I could just start coding away without too much afterthoughts. But the viability and speed of development are very much favoured by precise specifications. So if you have any other ideas or inspirations, just add them in the comments! I’m excited to hear them.

Client application

The client application is probably the most straight-forward part of the lighting system. The goal is to create an intuitive, appealing yet powerful interface to allow the user to interact with a central control system in simple ways. I had a few attempts in creating native smartphone apps for Bada, Windows Phone and also visited an Android workshop, but writing one app for each platform would vaporize any viable schedule I had. As I’m quite comfortable with web technologies myself though, I decided to go and try the web app route. Nowadays there are many great frameworks to pick from that makes JavaScript based applications extremely powerful, performant as well as beautiful in design.

I’m currently working on a web app based on Google’s open source AngularJS and Twitter’s Bootstrap. It took me several weeks to get to know them and rewrite my existing app with ordinary JavaScript, but these frameworks are simply amazing and a whole new world to work with if all you knew was jQuery and your own messy CSS. Pre-compilation languages like CoffeeScript and LESS CSS make writing web code enjoyable again. The JavaScript task runner Grunt helps in auto-compiling the code and streamlines my development process, so development is getting fast!

I’m driving a mobile first strategy with the app, making everything big and touch-responsive for smartphones and tablets. But the great thing about web apps is that you can use them in any browser, so you can control your light system from a regular website on your PC browser as well.

Lamp hardware and electronics

I have to say that I don’t know a lot about electronics. Unfortunately, my university curriculum doesn’t foresee any electric engineering classes at all, which I think is a huge bummer. I planned to visit some lectures just for the heck of it, but alas, there is never enough time. So most of my electric understanding actually comes off the internet and a few books. I really spent a lot of time, and I mean A LOT of time, like a whole month, just sifting through hundreds of websites and dozens of bookmarks to get my head around electronics, basic circuit design and optoelectronics.

My current focus is on designing safe and reliable circuits — being functional would be the cherry on top! My current LED driver board is super simple, although I’m pretty proud that I got to the point I kind of understand what it does and how to solder it together. The board is controlled directly from the Raspberry Pi GPIOs (general purpose input/output). My goal is to make it wireless and install a radio transmitter on both the Raspberry Pi and the lamp board, I already got the equipment but not the know-how yet. So this part has to wait a little bit. The pinnacle of achievements would be printing my very own custom PCB, which is just awesomeness in itself.

The other crucial aspect of the hardware is to get the light source right. Things as the actual RGB LED emitter, optics, reflectors as well as heat sinks need to be considered. Colour-mixing and achieving a smooth, consistent and predictable light projection is astoundingly difficult, as well.

Server-side

The service backend residing on the server is the heart of the project. Here is where the magic happens. The server provides interfaces for the client to sent commands to and request information from, like what lamps are currently available. The server keeps track of the system state, storing information for all the lamps and their individual states, e.g. colour, on-/off-status, etc. It provides a defined set of functions which can be called via the client to easily control the system.

Many seemingly trivial tasks turn into complex problems due to the fact that the system is a real-time application. It needs to be fast — the user doesn’t want to wait a minute or even just a few seconds for the lamp to change to the desired colour. There mustn’t be any notable lag or delay. Choosing the right system architecture is crucial. I am going with the Python server micro-framework bottle. I know that is not really in accordance of what I just said, Python is not deterministic and fitting for applications with hard real-time constraints, but it’s a trade-off for greater ease of use. The Python framework provides straight-forward ways to create web services with REST APIs and websockets.

An alternative would be nGinX, a server framework in C. It allows for great hardware control and fast response times if need be, but doesn’t offer many programming luxuries like Python does. On top of that, my programming skills in C aren’t exactly stellar, so that did factor into my decision as well.

Considering I announced this project pretty much way back in February, I know progress seems incredibly slow. But as it is with new work tools and technologies, you need to study them first and use them right the first time unless you want to redo most of it afterwards. I’m also committed to my university degree and am working part time as a software engineer, on top of that I’m a voluntary organiser of my Computer Science faculty’s job fair, which plans a big reboot of its corporate identity as well as website. I’m actually in charge of design! So, you could say, I’m a little busy. But I’m dedicated to work on this lighting system and try to find the time to see this through!

Leave a comment

Write a comment

Fields marked with * are required.
Don't worry, your email adress will not be displayed or shared with anyone.