Back to posts

Open Sesame

By Gys Muller Sep 29, 2014

Our new office is pretty awesome. It is in almost every aspect better than our previous digs, with the minor exception of the main door. With our previous office we had a small tag which allowed us to open the door; our new office requires a bulky remote with a button you have to press to disengage the magnetic lock.

Now, if you are like me and hate having a collection of items on your keychain, adding a bulky remote was never an option. The first proposed solution to this problem was to just throw money at it and pay to retrofit the door to work with a tag entry system, same as we had at our old place. Turns out you have to throw quite a lot of money, so we decided against that. Also a tag is only one step better than a remote and therefore would not have conformed to the FireWorks’ way of excellence.

My second thought was to build a Lockitron type system, which would allow you to disengage the magnetic lock and open the door by using an app on your phone. So that is what I did. The system would consist out of three parts; the mobile app, the controller to open the door, and the communication between the two parts. Lets start with the first.

We’ve used Ionic to build mobile apps for some of our previous projects, and since I had very little experience developing Android apps, and none developing iOS apps, using Ionic was a no-brainer.

The controller to open the door was a bit more difficult. It wasn’t possible to integrate it directly with the controller for the magnetic latch of the door, since it wasn’t located in our office. Instead I hooked up one of the remotes for the door to a Pololu USB servo controller connected to a mini-PC, and placed it in our office within range of the receiver of the controller of the magnetic latch. Using Pololu’s C# SDK, I developed a Windows app to control the USB servo controller. All I needed was a way for the mobile app to communicate with the Windows app.

The initial plan for the system architecture was to use a Node server and websockets to facilitate communications between the controller for the door and the mobile app. After I finally managed to get a proof of concept up and running, my colleague and wizard, David, convinced me that using PubNub would be much simpler as it eliminates the need for a server. I replaced the websocket implementation with PubNub, installed the mini-PC and servo controller setup under Carl’s desk, and the door opener was operational!

Windows is unfortunately not known for it’s stability running apps 24/7, and I found myself stuck outside the office quite a number of times. This unreliability, plus the fact that the remote accidentally got deprogrammed during one of the impromptu Windows updates, meant that I had to come up with a better solution. Using an Arduino was that better solution.

I’ve always known that having an embedded controller be effective, but it wasn’t until I saw that PubNub supported Arduino, that I knew we had to use an Arduino for the controller. Using an Arduino Uno with an Ethernet Shield, I was quickly able to replicate what I did the servo controller and mini-PC. You can checkout the code for the Arduino on GitHub. I also hooked up the Arduino to the button of our intercom system in our office, which if pressed opens the door, essentially as a substitute for the remote.

We now have a very stable solution which I’ve been using for the past 2 weeks without a glitch. Carl has even created a Hipchat bot called c3po which you can ask to open the door for you if you don’t have the app. Although currently c3po requires a bit more work ;)

We as builders have the power to make life easier, or at least more interesting for us, and it would be a shame not to use it. There is a quote from Paul Graham that I regularly try to adhere to: “Live in the future and build what seems interesting.”

comments powered by Disqus