Learning Arduino Kung Fu

Posted on: April 11, 2012 at 9:38am — By: Alex

When a postal truck arrives at the iFixit office with a delivery, we don’t even have to get up. All we have to do is tell our garage door robot, via our internal chat client, to open the roll-up door. Someday, I hope to put the robot to more exciting uses (ultimate goal: robot domination). For now, however, my T1000 does its door-opening job with no complaints.

The Problem

Several months ago, our Operations and Logistics Supervisor, Scott, told me about the daily annoyance of running from our upstairs office to our downstairs warehouse to let in delivery drivers. The engineer inside of me couldn’t stand letting so much energy go to waste, so I proposed an automated solution. The roll-up door was already motorized, so it was just a matter of figuring out how control the door remotely.

I didn’t have any more experience than the average iFixit user. I had coded just a little in Java and worked with the FIRST Robotics team in high school. I knew that I would need to learn a lot. But lucky for me, I live in The Age of Information. Harnessing the knowledge of the Internet, I figured I could create a system that would let Scott operate the downstairs door without leaving his seat.

After browsing several DIY websites and ruling out some less optimal MacGyver-esque solutions (turns out my boss, Luke, doesn’t want wires running up and down the staircase), I decided that an Arduino would be the best solution. Arduino, if you aren’t already familiar, is a open-source micro-controller used by artists, engineers, and tinkerers around the globe for small projects. I also decided to hook into our company’s Jabber chat system.

Writing the Chat Bot

I began with the chat bot, because I wouldn’t have to buy anything and couldn’t really break anything, either (I hoped). Since I didn’t have much programming experience, the one skill I knew would come in handy was Googling. I’m a world-class Googler. Each person has a different method to their Googling madness, but I like to start my searches simple then iterate. For the chat bot, I started with “chat program.” From there I swapped in synonyms and gauged how that changed my results, e.g. “chat AI,” “chat bot,” “Jabber bot.” Then, I honed in on results that showed up repeatedly, and used those websites as a primer: I learned about the Ruby language and how people share code building blocks called gems. That gave me the keywords “Ruby Jabber gem.” On that search’s third result, I found a code library for chat bots. Through a similar process, I found a tutorial in Ruby programing. Jabber bot check.

Learning to Use the Arduino

Next, I had to get the Arduino talking back to the Jabber bot. Since one of Arduino’s target markets is artists and non-engineers who have no experience, I hoped there would be a lot of information available to help. Sure enough, I found an explanation of Arduino options from Sparkfun, so I bought an Arduino and an Ethernet attachment from them. The Arduino came in the mail in a neat custom-made Sparkfun red box. It was like Christmas morning for a techno-geek. On the Arduino site, I found an an Integrated Development Environment (basically, a program that helps you write programs) and tutorials for programming; it was all pretty simple.

Wiring It All Together

Now came the last and most difficult part: wiring it into the door. I pulled out my multimeter and started testing the cables on the control panel. Slowly, I was able to reverse engineer the mechanic of each button and figure out to hack in. Most of the functions were controlled by simple open/close circuits. I could wire a relay in parallel with the button to control those. Having never used an Arduino before, I knew that I wouldn’t stumble upon the correct wiring method by accident and once again turned to my ol’ pal Google for some insight. Soon, I had found a great Arduino forum, with a post for wiring relays to high voltage systems. And with the sweet smell of solder still lingering in the air, Alex’s T1000 was born! It now is used daily to let in delivery men (and scare passersby).

With the ability to find resources on the Internet, I was able to augment my limited knowledge of programming and electronics and create something cool. That, in my mind, is the true value of the Internet. It’s an incredible living library, with the sum total of human experience compressed into easily searchable fragments.

There is a pivotal scene in the first Matrix movie, when Neo is first being introduced to the wonders of the Matrix. His shipmates can plug into his brain and upload any information that he requests. After one upload session, he leans over to Morpheus and says in astonishment, “I know kung fu.” We may not have plugs in the back of our heads, but our computers are the next best thing.

Here at iFixit, we’re adding to the collective wisdom of the Internet. We want to help you do something you’ve never done before. That’s why we’re collecting tons of information about repair, making it easy to read and search, and giving it to you for free. That way everyone can, as Neo puts it, know kung fu.

Comments

great idea!

You might want to put a disclaimer that anyone using a device like this should not utilize it unless they can clearly view the door being operated.

Most older industrial door operators lack inherent obstruction sensing or anti-entrapment capabilities.

My concern is that you could possibly crush someone or something if you are operating the door without ensuring the door path is clear.

Otherwise I love it.

By: scienkoptic - April 11, 2012 at 2:06 pm

@scienkoptic
For security reasons, I left out a lot of info about specific case uses and safety features, but you’re right this was a concern of mine. And I’ve got a few features in place to counteract it.

For example closing the door is disabled for most users, and those who can close the door are aware of this safety issue.

By: Alex - April 11, 2012 at 2:18 pm

I’m looking at implementing an almost identical solution. Could I get a basic wiring diagram or a closeup photo showing the wiring between relay and existing push button? Do you have any issues with overriding the buttons? What voltage is the button operating at?

Thanks for any hints.

By: Matt Watson - April 11, 2012 at 5:58 pm

@Matt

Here’s the wiring diagram form the forum post I linked in the article. I followed it exactly.

http://www.arduino.cc/playground/uploads/Learning/relays.pdf

By: Alex - April 11, 2012 at 6:01 pm

open and close are both Normally open inputs.
Stop is normally closed.
This is typical of most overhead door operators. But there are exceptions!

if using relays, you would typically need three relays. SPDT would work.
the open and close relays would be wired parallel to the buttons. The stop would have to be wired in series with the stop circuit.

Late model units with logic boards are typically 5VDC logic.
But many utilize 24VAC controls. It is entirely possible to find 120VAC controls, but rather uncommon.
In most cases, if the equipment isn’t too old, you should be able to find a service manual for your equipment online.

By: scienkoptic - April 11, 2012 at 8:38 pm

Interesting write-up – but your links are odd. Instead of going to the sites themselves, they go to a Google search? And instead of linking to the current Arduino forum, you link to the archived one?

By: Dan - April 12, 2012 at 6:39 am

what happens when one person issues ‘open’ command and the other issues ‘close’ command?
you’d better use optocoupler for galvanic separation of the high-voltage part from the arduino and your network. I didn’t get, you created a jabber-client in arduino?? Or is it just a jabber bot that sends udp commands to arduino?

By: serjio - April 12, 2012 at 9:08 am

@Dan
Which link goes to a Google search? I was linking to a the specific post where I found the wiring diagram, not the forum in general.

@serjio
I’m under the impression that the relay keeps the two systems electronically isolated. Is that not true?
Unfortunately, for security reasons (that door gives access to our warehouse), I can’t share some key specifics about how the jabber bot works.

By: Alex - April 12, 2012 at 1:46 pm

Dang if you can program an Arduino that means anyone can.. woody haha I am actually surprised that you got away with only using one transistor, how many amps are going though the relay? and you are correct the relays do isolate, however the thing to watch out for is that when they trigger on and off for a split second they can cause current in the reverse direction, but a simple diode on the trigger pins will solve that. as far as the optocoupler I generally use those for high switching applications like using TRIACs to dim ac lights.

By: guess - November 6, 2012 at 9:00 pm

Comments are closed