An Arduino/Dancer-enabled mobile-enhanced door

So you're sitting at home, preparing for a karaoke night, waiting for your friend to arrive. She comes in, rings the doorbell and you're thinking "fuck! I'm upstairs, and she's downstairs and I have to open the door for her (because it's locked) but I'm busy changing my clothes." What do you do? WHAT DO YOU DO?

What if you could let her in using you phone while you're still upstairs getting yourself ready? Arduino could be used for that. And the following is a theoretical (and slightly bit practical) explanation on how you could use Arduino and Dancer to accomplish this.

Arduino is a basic unit. You can set bits on and off. You can hook the bits to other devices (sound, video, screens, you name it!). You can write firmware to it. That's awesome. You can hook up more shields (components) to it. That means you can have additional hardware like an ethernet hookup or whathaveyou.

You start by connecting an Arduino to the door. This can be done by hooking up the bits to a rotary engine that can unlock the door. Next you add an ethernet shield on top of Arduino. This will allow Arduino to connect to a network using a cable (or wirelessly perhaps using a wifi ethernet shield). This means you can now hook up Arduino to your local network (and possibly onwards to the internet from there) and get an IP and reach it via TCP/IP.

The Arduino IDE (older versions available on distribution packaging, newer versions on the Arduino website) comes with a bunch of useful and interesting examples. The way it works is that you open the editor, open in the editor a new Arduino script file, connect Arduino using USB, and now using the IDE you can compile and script and upload it to Arduino as firmware.

One very useful firmware example is a web server that can raise bits when you go to a specific path and returns JSON output back. Once you set that up, you can run cURL commands from your network to the IP Arduino has, and it will unlock the door. Hey, you're more than half-way there!

Next one up is even easier: you set up a Dancer application (R. Geoffrey Avery did a talk on how to set up Dancer + Starman + Nginx - check it out!) that once you hit a certain route, it will run an HTTP request (whether LWP::UserAgent, WWW::Mechanize, HTTP::Tiny or anything else) to the Arduino web server to raise the correct bit.

Of course you set up a nice web interface to display buttons to click on that run the correct route in the frontend Dancer application that calls the correct path in the Arduino web server that runs the rotary engine it's connected to, in order to unlock the door. It really is that simple.

You'll probably want to constraint that to the local network, or at least to an authenticated user (which is really simple in Dancer) in case you want to open the door for people who are crashing at your place while you're away.

Of course we haven't yet spoken about hooking Arduino to a webcam so you could view it remotely on your cell phone (hint: Robert Blackwell has already done something along these lines!) and see if anyone shows up, and what they're doing, and if they left the door open. Yes, an Arduino with an engine that closes the damned door! It's also possible! The imagination is going nuts over how many things are possible here!

1 Comment

I've been playing with an Arduino lately, mostly with temperature/humidity sensors as well as the 3-axis accelerometer. One of my gripes, of course, is that I have to use C instead of some Perl. I saw there is an LCD module on the cpan but haven't actually had a chance to use it.

Are you guys banging away at C for these experiments? Thinking of developing some more Perlish way of doing it? If so, I would be interested in helping out.

And yes, the Arduino rocks. Very fun and geeky.

Leave a comment

About Sawyer X

user-pic Gots to do the bloggingz