Introduction: Automatic Loft / Attic Ladder
So I recently had the brainwave of moving my home office from the "box room" to the Attic, after I scored some free wood from a family member that was doing up her home (thanks Tricia!).
Considering I work a day or so a week from home, I decided I needed ease of access to the attic/office going forward.
- The ability to close when I'm in the attic (to stop my little ones climbing/falling off!)
- Ideally something a bit of fun to work on which I could "hopefully" integrate with my home automation system.
So hope you enjoy this instructable!
Step 1: Decisions.. Decisions... Decisions..
So the tough part was to try figure out what type of attic ladder I wanted.
I gave it plenty of thought, and found one company that manufactures and sells their own fully-automatic attic ladder in Ireland called LoftEase (http://www.lofteasestairs.com/).
I reached out to see how much it would cost, and at the time I looked into it, it was going to cost around €2,500 (US$2,800+). This was obviously waaaay out of my price range(well, outside my "WJR"- Wife Justification Range). So I decided, feckit, give it a lash to build one yourself!
So I managed to track down a nice and cheap one in a local hardware store (Thanks JTs!) for around €95.
Step 2: Attic Stairs Installation!
So I realised my hole was irregular (insert jokes here). This meant having to give some serious thought on paying someone to do the work, or giving it a lash myself!
Anyhow, I decided feckit - go for it.
1. So I started ripping down the wood frame around the existing hole.
2. Drew the new opening on the ceiling.
3. Cleared the insulation from above.
4. Cut the opening.
5. Reinforced the rafters above.
6. Installed the stairs.
7. Filled the hole with some spare chalkboard I had on-hand and some filler.
8. Re-attached the steps and job done.
Step 3: Mechanics - Step 1 - Attic Opening Automation
So I started looking into the mechanics of the situation.
Firstly I realised I needed an actuator for the opening and closing of the attic hole itself. So in true form, I just went ahead and ordered a linear actuator from China, considering I knew it'd take 3-4 weeks on the slow-boat, I said feckit - just order it!
I guessed something around 18" or so would do, so went with that!
Once I had that actuator, I started to make some modifications to the existing mechanism. See photos!
Step 4: Mechanics - Step 2 - Stairs Automation - Lower Section
As one of my main requirements was to be able to close the attic door when I'm working in the office, I needed to be able to automate the full extension of the ladder.
I decided to go down the metal wire/sprung approach to fold out the bottom section.
As a wise man once said, it was all a bit "shur just give it a lash" - and figure it out on the fly.
Step 5: Mechanics - Step 3 - Stairs Automation - Mid Section
This was really the toughest part to figure out.
I initially figured I could use a motor attached to the hinge, and use that to bring up the steps, but through all my trial-and-error, I found that it was just simply too much weight to move.
I came around and figured that linear actuators were also required for this section, as it was really the only method with the pulling/pushing power required to move the legs. I was surprised at how heavy they were once being lifted from the hinge (physics eh!).
I thought of going down the "rack and pinion" route, which I believe is what I assume is how some of the commercial units operate, but it was all a bit "requiring of welding", and considering I'm a desk-jockey, I don't even have a welder at my disposal.. so figured I'd steer clear.
Then I guess one could say I "got by with a little help from my friends". Thanks DV, you knocked across this idea/video which really helped shape the next steps;
From there I got to work chancing my arm with various lengths of pivots, and of course, just started drilling into the steps! :) shur why mock something up when you can modify the real thing :D
Once I finally managed to get the actuator I had(for the attic opening) working well with the steps, I went ahead and ordered some additional actuators from the same seller in China. http://www.aliexpress.com/item/A-Pair-of-2X-Stroke...
Step 6: The Electronics..
So... now that I have a fully mechanised stairs, I have to turn my attention to making it somewhat intelligent.
(after all, standing there holding a battery and never being able to close it, just aint that practical...)
I had bought an Arduino for another project which I hadn't gotten around to starting.. so figured, feckit, go for it.. note, I had never used an Arduino up to this point...
I decided to go off and buy a Motor shield to drive the actuators, and in my standard style, I wanted it NOW... so drove to the nearest Maplin(www.maplin.co.uk) and found their Motor shield. (http://www.maplin.co.uk/p/motor-shield-for-arduino...
So armed with an arduino, a couple of actuators(3 actually.. strange couple.. luckily I had ordered a spare, so I could leave the two on the ladder in place), a motor shield and some batteries.
I had to figure out how to drive this thing. so I went looking for some Arduino code to drive a motor with the shield I had. (http://linksprite.com/wiki/index.php5?title=Motor_... gave me all the info and code snippit I needed.
I was from there able to go sit at the kitchen table with my laptop, the spare actuator and the arduino, and go try move the actuator with my mind!(I mean, arduino code). I found using the Arduino IDE and all the bits and bobs pretty damn easy. Within about 15 mins I had the actuator going in and out driven by the arduino.
I then had to figure out how to get the Arduino to take commands over Serial, so found a very helpful tutorial by Alex(all credit to him) here - http://www.seeedstudio.com/recipe/166-basic-pi-lt-...
So I took the code to drive the motors and merged it horribly with the code provided by Alex, resulting in my mishmash of barely functional code.
Next was off to the staircase and try this thing out.
Step 7: The Timing..
I didn't have any microswitches at the time I built it out, so I just went with the timing approach.
- i.e. move the door actuator forward for x second. Then move the stairs actuator forward for y seconds.
So I simply set the actuator to go for 2 seconds, I then repeated that until it went as far as I wanted. Counted them up, and changed the code to go that long. Simples..(albeit a dangerous/dodgy approach, still works).
I was then in a position with this that I could drive the whole thing off my laptop whilst connected to the Arduino.
Step 8: Making It Wireless..ish...
So being very new to the Arduino, I also bought the amazing ESP8266... however.... I didn't bother going to try figure out how to connect the ESP to the Arduino via the Motor Shield...
So I took the extremely lazy approach.... I had a Rapberry Pi laying around, which has my zwave module installed(for my other home automation stuff).... I also had a switch in the attic/office, so simply ran a big dirty crappy cable from the swtich to the Pi, then the Pi to the Ardino via USB.
I have to say, this is very much a temporary arrangement.... whch I will probably simply never change out, but hey...
So I now have some Python scripts on the Pi, activated by a PHP page which sends the necessary commands to the Arduino via USB. Again, I know this is a hideous approach... I was going for something like myself, i.e. hideous but functional.
I'll include all the necessary code and stuff here too btw for the php, python, arduino, etcetera.
Step 9: HomeGenie "integration"...
I use the term "integration" very very lightly here... I'm no developer... so I just hacked stuff together, which works for now... but needs plenty of tidying up.
I created a widget in HomeGenie(running on separate vm on my ESX stack), which I was able to configure to make two different php calls, one for opening and one for closing the attic.
These calls are made to the php on the pi, which calls the python, which tells the arduino to run the necessary code segment... (the leg bones connected to the... knew bone... the ....).
Step 10: The Parts List... (where I Realised €2500 Was Cheap..)
So here's as full a parts list I can give....
1. 1x actuator for Door (18") + mounts.
2. 1x actuator for stairs (12") + mounts.
3. 1x Arduino Nano + ESP 8266(unused).
4. 1x Arduino Motor Shield from Maplin.co.uk
5. 1x 12v power source (Battery for testing and/or plug for live).
6. lots of nuts and bolts and stuff.
7. Time... oh, and very patient wife & kids I guess! (Thanks guys!).