Remote Home Automation
Introduction: Remote Home Automation
I've wanted to post this project for about 3 years now but never could find the time. Oh well needs must as the devil drives as they say and it's here for you now. I hope it comes across clear, if not let me know and I'll fix it. With that said:
Home Automation systems are cool. You can use them to control your music, home temperature, lights, theater systems, sprinklers, HVAC, alarm system etc. Think of the Jetsons without the flying cars or stupid clothes. That's what the 21st century is supposed to be like folks, and it's not going to come on it's own we have to build it.
Back in 2007 and 2008 I made a Home Automation System as a part of my senior design project, and to automate some of the tasks that I come across in my daily life. While this project is still far from complete, and what I present here is just the tip of the iceberg, it is a great starting point to get your feet wet, and to build upon. I'll try and cover all the basics of what and why I chose to implement what I did back then. I'll also post a bunch of upgrade plans that can be easily implemented.
If you have any questions, comments, criticisms feel free to let me know this is my first instructable. If I did the system over today it would be a little different cuz I've learned more since then, tech has changed, and I no longer have a home phone line which the heart of the system relies on. Just don't measure my choices then based upon todays yardsticks. Some parts will get pretty wordy, but I'll try and load in Pics to help with that along the way. Hope you have as much fun with it as I have!
I mean this instructable to illustrate many BUILDING BLOCKS that can be used in your home automation system. Please treat each subsytem as a lego block, if you want to use it go for it, if you think it dumb ignore it.
(As a fair warning I can get wordy skip it if your not interested! Feel free to tell me where I messed up I wont take offense.)
This will also be my entry into the 3rd Epilog challenge, as well as the Makerbot Challenge I wish I had another month to update the info because there is a lot more, but I hope you like it as is.
Step 1: What Is Remote Home Automation (RHA)?
Home Automation is a little different from Building Automation although they are pretty similar. Automated houses or smarthomes are usually distinguished by their ergonomics (or how they interface with people) and are made to have a little flare to them. Whereas most other building automation is strictly functional.
Examples of home automation include the clapper, the X10 series, and the HAL 2000 software .
Basically think of it as making your home into a giant robot. With different sensors, and systems to make your life easier.
Given above is the block diagram for the system we'll be focusing on. The Phone will be our initial interface for triggering subsystems, later I'll show how you can interface this with the computer and then automate more stuff from there.
There are an endless number of things that you can do to automate your home. Here I'll present a few of the building blocks for one such system. I intend for these systems to be used more like lego pieces so use them as you will. :)
Step 2: Why Build RHA?
There are lots of reasons to build an automated home. Primarily people build advanced houses because it's cool. Other more practical reasons are because a person is either injured, elderly, or infirm in such a way that they can't do everything they used to be able to do.
MY reason at the time was my wife was diagnosed with degenerative disc disease and scoliosis. Basically she had a REALLY bad back and couldn't always do everything she liked to do. Occasionally it got bad enough she couldn't get out of bed. So I would try and do extra stuff for her like feed her plants and keep the house clean-ish. That was a little tough with how much I was gone for school and work at the time so I made this system so I could do a few things to help out when the day was particularly not cool for her. (I also needed a senior project which this fit the bill nicely)
The final reason to build a home automation system is so that you can prove just how much work will will do to avoid having to stand up walk across the room and open the blinds. Because darn it all, they are ALL THE WAY OVER THERE!
Step 3: Materials & Skills List
For this instructable I assume you have basic electronics skills, namely soldering & following a schematic, also that your comfortable reading/writing code for a microcontroller. Where applicable I have included links to help put you on the right path if you don't have these skills at your disposal.
Here's a small list of materials used. Albeit not complete for everything I will be attempting to describe.
Materials:
DTMF Decoder Sub-system:t terminal
Plant Watering Sub-system:
"Curtains": arround)
12 Vdc Wall Wart
Connecter socket that matches wall wart
7805 Voltage Regulator
RFID Door Unlock:
RFID Tag Reader
RFID Tags
Electronic Door Strike
555 TImer
Project box
220 uF Capacitor
1800 uF Capacitor
90k Resistor or 100k potentiometer
10k Resistor
5Vdc Solid State Relay
12 Vdc Wall Wart
7805 Voltage Regulator
General Use:
Wire
Solder
Heat Shrink tubing
Zip ties
Various Screws & Nuts
JB Weld
Time
Patience
Okay.... that's not such a small list and I'm not sure I even got it all, I will repost this for each subsystem section so you don't have to keep referring to this page.
Budget:
I made mine for about $400 back then, but that was with trial and error and buying stuff I didn't end up using, the heart of the system (DTMF decoder) can be made for ~$20 and subsystems can be cheap or real pricey depending on what you want.
Step 4: Where to Get Components
Buying electronic components for cheap is an art in and of it self. There is no 1 place to go for parts. That being said most cheap parts I order from Futurlec , Digikey , and Mouser . Futurlec is the easiest & cheapest to find general components on but comes from China so its got a long shipping lead time. Digikey second with a much larger range of options and if I can find it at mouser I will usually get it there because they have this nifty project manager feature that allows you to order stuff as clumped projects and look it up years later, this is especially nice when I look at a part from one project I want to put in another but don't want to look up all the other parts along with it. The project manager will store them all right next to each other for me, and suggest replacements if one is no longer made.
For the RFID doorlock I got both the electronic door strike and RFID reader from ebay . Just look up "Door Strike" and "RFID reader" and sort by price and you'll find the two I use in this instructable, and I bought this stuff about 4 years ago. Same with the stepper motors, but you will just have to look around for a good deal.
For the microcontrollers and any little modules that will shorten development time on this and other projects I used sparkfun.com . I don't think they carry the smaller attiny2313 any more which I used for this project, but you can upgrade it to a ATMega328, or ATMega128 (suggested), and pick up a nice breakout board there as well.
Finally I'd also look and see what they have over at the aptly named electronic goldmine you can pick up all sorts of sensors and things that are useful for home automation systems.
Step 5: Tools & Where to Get 'em
You'll need a variety of tools for this project. I can't stress enough having the right tool for the right job. When I did this I owned 1 saw... a small hacksaw because it could cut metal. Oh yes it works fine on wood too, but it takes longer, is a pain, and isn't meant for that job. Do yourself a favor and never stop collecting tools, having the right tool saves time, energy and money. That being said here are some of the more important tools I used:
Tools:
Dremel or other rotary tool
Computer/Laptop
Soldering Iron
Atmel AVR programmer (I use the USBtiny from ladyada )
Drill/Screwdrivers
Hot air gun (read the manual)
Hot glue gun
Chisel
Saw
Safety Glasses
Work Gloves
Hammer
Pliers
Multimeter (I would suggest one with a continuity setting... will save your sanity!)
Oscilloscope
Bus Pirate would be handy too
Most of these are available at you local hardware store, or harbor freight if your low on the cash. You can make substitutions where needed, but no matter what you end up using: USE THE RIGHT TOOL FOR THE RIGHT JOB!
Step 6: How to Solder
The best breif guide I've seen on hand soldering can be found here from NASA. If you've not seen them even if you know how to solder go watch them. More in depth soldering guides are available from the guys at Curious Inventor
To sum it up:
1. Make sure your iron tip is clean & well tinned
2. Wet your sponge
3. Pre-tin the things you are going to solder, or use flux
(don't always have to do this one, I usually only do this for wires)
4. Hold the two items being soldered together
5. In just a second or so of time:
a. apply heat to the surface being soldered
b. apply solder
c. remove soldering iron and solder
6. Clean the tip of your iron on the sponge
7. Re-tin the tip of your iron
Step 7: Microcontrollers:
I won't try and do a comprehensive list of how to program micros, but I will cover enough steps to get you started. There are better lists out there, lots on instructables (in fact I learned this here about 5 years ago). That being said I'll try and give lots of external links to help out.
Favorite Links for Microcontrollers:
avrbeginners
hackaday tutorial
AVRFreaks
Sparkfuns Beginning Embedded Tutorials
My choice of Microcontrollers is the Atmel line of 8 bit AVRs. The main reason for this is they were the cheapest & easiest to learn when I got into the hobby and now I'm hooked. There is a huge community of users and the open source tools are both powerful and customizable.
If you have another micro you are fond of feel free to substitute it any time. The TI MSP430s are great for low power which many home automation systems need to be, and the STM8s and STM32s look pretty nice too. Don't feel limited to only one micro, there are lots of great options out there.
Step 8: Sub-System Choices
Subsystems:
There are many potential subsystems that can be implemented in home automation. Anything from turning on and off house lights to feeding a pet can be accomplished. The following table summarizes several of the initial ideas for subsystems.
Some Potential Subsystems:
Open/Close Curtains
Water House Plants
Feed Pets
Toggle House Lights
Lock/Unlock Doors
Play Music
HVAC Control
Opening and closing the curtains, watering house plants, and latching/unlatching the front door are currently the most useful subsystems to me. They also demonstrate things that are useful to activate while being incapable of doing them by oneself, either from being ill, or absent.
There are many alternative design choices that could be made in this system. Each subsystem offers alternate approaches of their own, so alternative designs will mainly focus on the different choices available through user interfacing every subsystem will have a direct trigger option such as a switch or button. The next version of each subsystem will incorporate wireless communication and addressing to trigger the subsystems. For now the main subsystem will just toggle a transistor to activate the subsystems.
The main system types can be divided into two groups: direct actuation triggers and triggers that are created while traveling. The systems that offer control from a distance can also be used while at home, which makes them far more useful in the long run. A potential third group would be automatic triggers that occur naturally without the need of a user to be present. Automatic triggers offer the highest convenience but are more of a solution to trigger subsystems on the subsystem level instead of offering user control.
Based on the topics and ideas discussed above, a distance actuation system employing DTMF decoding will be used for the first user interface. The first three subsystems will be an indoor plant sprinkling system, a window curtain driver, and an electronic door opener. Then a simple security system, and adding IR as a user interface to connect to a computer. The final design details and implementation steps of each of these systems will constitute the remaining bulk of this instructable.
The circuitry for each of the designed subsystems can operate off of a 9-12 Volt input. The input voltage is then reduced to 5 Volts using a common LM7805 Voltage regulator. This is a simple circuit to build and can cost less than $1, including external components. Depending on the input power, the circuit may require an external heat sink, but generally will not for our power consumption needs. The 7805 usually supplies up to an amp of current which is well beyond what any of the driving circuitry will draw. All of the following subsystems use this chip with a 9 Volt 200mA power supply to power their on board microchips unless otherwise stated. A typical 7805 setup can be seen in the above schematic.
Step 9: DTMF: What Is It?
The main system is the user interface and control system. The phone line was chosen as the method of interfacing because it has distinct advantages over other systems in communicating information from a distance. The method of sending simple commands across the phone line is also already provided by the keys of a touch-tone telephone. When a key is pressed, a unique tone is played. The tone is actually a combination of two separate frequencies and the signaling touch-tone system is more appropriately called Dual-Tone Multi-Frequency (DTMF) signaling.
You can see what this signal looks like in the image above. I've also included a table that shows which key presses correspond with what frequencies. There are other standards defined for DTMF including key presses A-D as well as the signal used to cause your phone to ring and everyone favorite dial tone.
Step 10: Why Choose DTMF?
So now that you've seen the anatomy of a DTMF signal why did we choose it vs. say other methods?
Well DTMF was designed for the purpose of actuating systems remotely from a distance (hmmm...sound familiar?) and the chief concern was to ensure a reliable recovery of the transmitted signal. As a result, DTMF was designed with various characteristics to isolate it from potential noise. These characteristics include:
o Each DTMF signal is just under a whole tone.
o None of the tone frequencies are the sum/difference of any other two tones.
o No tone’s frequency is a multiple of any another.
o Valid DTMF signals must vary by less than 1.5% of the designed frequencies.
o The higher four frequencies can be a maximum of 3 dB louder than the lower frequencies.
Basically it's a well established, easy to use, and reliable system. Perfect for our first user interface.
Step 11: Isolating From the Phone Line
The DTMF Decoder must be isolated from the regular phone line to prevent it from getting fried from voltage spikes or other transient signals or noise that could come in from the outside world.
There is often protection circuitry installed in commercial hardware such as an answering machine. Also answering machines are both cheap and readily available in thrift stores. Interfacing the system with an answering machine also handles hanging up the phone when the call is completed.
You can also use a cell phone that auto answers after a few rings. I'll describe later in the instructable how this can also be used as a GPS car tracker on the cheap :)
Aside from relying on some other manufacturer to protect our circuit from the phone line we have a schematic shown which is the circuit that takes care of isolating our chips for us so we know we are protected.
The Audio Isolation transformer can be picked up at radioshack , and I used a standard wall phone jack that I dremeled down to size for the phone line input. The rest of the components are probably easiest to pick up at an online retailer.
The phone plug is a regular RJ11 plug .
Step 12: Decoding DTMF
DTMF tones can be decoded and converted to digital signals. These signals can then be used by a microprocessor to determine if an appropriate series of digits was entered by the user. If the correct code is entered, the microprocessor will activate one of the subsystems. Multiple codes or one code with an options menu can be used to activate the appropriate subsystem.
There are many ways you can decode DTMF including:
The Goertzel Algorithm
Band split filters & pulse counters
Premade chips for decoding:
- CM8870
- SSI-202, 203, 204
- MSM6843
- MC145436
- MC68HC05F5-µP
I've looked at several of these, the easiest to use and understand is the CM8870 chip. It acts kind of like a decoder ring that spits out the binary value of a DTMF signal. The CM8870 actually implements the bandsplit filter and pulse counter method which is illustrated from a MATLAB screenshot taken of the DTMF decoder file written by Randolf Sequera. If you'd like to play with it you can get it over at the MATLAB file exchange .
Step 13: DTMF Decoder: Hardware
Materials: terminals
This schematic shows how the last few circuits connect together and feed into the ATtiny2313.
The output from the 2313 to toggle the subsystems is shown at the top left of the 5th picture. These were just wirewrap sockets I could jumper to the other projects. I would update them to be wireless addressable units now using something like a zigbee , and I'd update the schematic to not use the ATtiny2313's serial pins for the DTMF input, but the circuit shown will work just fine.
One of the funny things I came across was that my CM8870 was not putting out 5V as I'd expected. It was actually floating in the range between a logic high and a logic low on the ATtiny2313, faced with it not working for my upcoming project demonstration and hacking it I chose to use hack it. I didn't have a logic level shifter or much else so I decided to drop the ATtiny2313's operating voltage which would in turn lower the threshold voltage for a logic level high.
All I ended up doing was making a voltage divider with a few spare resistors feeding the ATtiny2313's power.... horrible design I know... but it worked and got me through my review. You can probably leave this out and just connect the 2313 to 5V but be prepared to do something funny if the CM8870 output is finicky.
The last schematic should be the same as the first but without the voltage divider.
Step 14: DTMF Decoder Code (Assembly & C): Programming an Atmel AVR
Here I'll explain the code a little bit, the next few steps will be a tutorial on how to load it into the ATtiny2313 using an example program, but the same steps will apply for all the code we have for the micro-controllers.
I've included both the assembly and C code for this circuit. They should be pretty similar in function. The C code just forwards what is read by the ATtiny2313 onto Port B from Port D, this is so that you can verify that the signal is coming in correctly with nothing more then a few blinkinlights on the lower 4 pins of Port B.
The default code is 0000 and can be changed on line 99. Once you've entered the correct code hit the # button on your phone to have the micro validate the code. If you mis-press a key don't worry, just keep entering numbers the micro will only remember the last 4 digits entered.
Once your that far and you can see the DTMF codes being read correctly by the 2313, un-comment the large block of code on lines 118-121, and 123-261, and comment out line 122 to enable regular functionality.
Lines 233-238 will contain the code you want executed once a valid code is entered. Port B is totally free so for a low # of sub-systems you can just have the next phone key presses activate subsystems directly on the port. Another option would be to have this section send a serial command out to either a computer or other subsystem.
There is a lockdown mode for too many invalid characters being entered, I defaulted it to 2 seconds for your troubleshooting but once working I would encourage upping this to a few minutes or more for security. Lines 320-332 have the lockdown code.
Ask any questions if you have them and I'll try and explain the mad state I was in while coding this. It is fairly well commented though and shouldn't be too hard to decipher.
Step 15: Download Development Enviornment
Now that it's time to dig into!
Step 16: Create a Makefile
Lets see how can I explain these... Lets say your a person that doesn't know anything about cars and your development environment is a car. Then a makefile is like your cars engine. Its powered by all sorts of tomfoolery and witchcraft that you don't need to worry about right now.
Just include the one I've left here, in your codes main directory. If you are using a different microcontroller then the attiny2313 or would like to use a bit of code with a different name then TEST_2313.c you will need to edit the makefile just a little.
To do so open the WINAVR program named MFile and with it open the make file I've included. If you are using a different microcontroller then me change the first highlighted name from attiny2313 to the name of your micro. If you want to use a C file with a different name change the second highlighted value to the name of your file (it IS case sensitive and you need to leave off the extension).
Notice you can't edit the make file..... to enable edititing of the make file goto: "Makefile >> Enable Editing of Makefile" and type away to your hearts content.
Step 17: Load Code Into Programmers Notepad
Once your makefile is squared away open the WINAVR program called Programmers Notepad.
From the main menu select File >> New >> C/C++
Paste the below code into the editor and save the file as TEST_2313.c making sure it is saved to the same directory as your makefile.
#include <avr/interrupt.h> // Defines pins, ports, etc to make programs easier to read
#define F_CPU 8000000UL // Sets up the default speed for delay.h
#include <util/delay.h> // Allows for delay to be used
#include <avr/io.h> // Enables IO
//**********************************************************
// Main Program
int main()
{
DDRB = 0xff; // Set Port B data direction register to be outputs
PORTB = 0x03; // Turn on Port B Pins 1 & 2 (0b00000011)
while(1) // Repeat this code forever
{
for(int i = 0; i < 250;i++)
{
PORTB = 0x02; // Turn on and off, Port B Pin 2, 251 times with a 1/4 second delay
_delay_ms(250);
PORTB = 0x03;
}
/* This is how you comment out a large block
for(int i = 0; i < 250;i++)
{
PORTB = 0x00;
_delay_us(250);
PORTB = 0x01;
}
*/
} // end while
return(0);
} // COPY CODE ALL THE WAY DOWN TO HERE !!!!
Step 18: Compile Code
To compile your code inside of programmers notepad click on Tools >> [WinAVR] Make All.
If you've followed up until now what this will do is take the example code from the last page and create a hex file. This is a file that can be read by the microcontroller.
This hex file should be saved in the same directory as your C code and makefile, along with a whole bunch of other stuff you don't need to care about right now. Take the hex file and copy it into the same directory as the program avrdude and get your programmer ready to burn your first microcontroller.
Step 19: Connect the Programmer to the ATtiny2313
Open avrdude:
Open a command prompt by going to Start >> Run >> cmd >> Enter.
Then inside of the command prompt go to the directory where WinAVR's avrdude program is hiding.
Connect Your Programmer:
Each AVR requires 6 pins to be programmed. These are:
MOSI - (Master Out Slave In, pin 17)
MISO - (Master In Slave Out, pin 18)
SCK/SCL - (Clock, pin 19)
Voltage (pin 20)
Ground (pin 10)
Reset (pin 1)
Connect these 6 pins from the programmer to the chips identically named pins. The programmers usually will follow Atmel's defined pinout for the ISP (In System Programmer) which I've included in the pictures. You can just jumper them over, or build a breakout board like I did to make programming lots of the same chips easier. The guys at Evil Mad Science have made a ATtiny2313 breakout board that easily replaces the board I have shown. Just solder in a 6 pin header and a Zif socket and you are good to go.
Also ensure that your chosen programmer is providing power to the micro. If it doesn't do this you will need to supply the chip with 5V externally, don't forget to connect your ground to this external ground!
Step 20: Loading Code Into the ATtiny2313
With AVRdude open, your microcontroller receiving power, and your programmer connected it's time to learn how to use AVRdude.
Check that AVRdude sees the ATtiny2313 by typing the following command:
avrdude -c usbtiny -p t2313
This line says we'd like to program an ATtiny2313 using the usbtiny programmer. If you are using a different device or a different chip you can type
avrdude -c 6
to get a list of valid programmers
avrdude -c usbtiny -p 6
to get a list of valid microcontrollers. If AVRdude could not find the device it will say: "Could not find...." If AVRdude could find the usbtiny programmer it will say "avrdude: Initialization failed...." I know it sounds weird, but trust me it found it.
To program your hex file onto the chip type:
avrdude -c usbtiny -p t2313 -U flash:w:XXXXXXXX.hex
substituting the name of your file for the XXXXXXXX's given above.
If you ever get stuck just type 'avrdude' then press 'enter' and a list of commands will pop up.
A great tutorial on using AVRdude is available at ladyada's website
Once you're comfortable with AVRdudes functioning go to this Sparkfun tutorial and setup programmers notepad to do the programming for you with hotkeys. You'll still need to know how to run AVRdude, particularly when you need to burn the fuse bits... speaking of which:
Step 21: Burn the Fuse Bits
The AVR fuse bits are special bits that change certain things about your micro such as if you want to allow someone to read the hex file saved on your AVR or not. We'll be using them to tell the micro-controller to not use the internal RC oscillator anymore, but for it to start running from off of an external crystal. This gives us more speed and a more precise clock.
Ensure that your crystal and bootstrap capacitors are connected before you try and burn the fuse bits. If your micro now wants to run using it's external 20MHz clock and it doesn't have one well, it will look like you killed it (you didn't you just need to clock it properly but still it can be aggravating finding this out later on).
Also you can let the magic smoke out if you decide to go mucking around with the the fuse bits and don't' know what you're doing so be careful.
To reprogram the fuse bits :
1. Hook up to program the AVR as normal
2. Open AVRdude and type:
avrdude -c usbtiny -p t2313 -U lfuse:r:-:h
This will READ the low fuse byte (the one we care about) from the ATtiny2313.
Referring to the Table in the images: the results of the above will give the default settings of the internal RC oscillator running at 8 MHz, but CKDIV8 results in an actual clock speed of 1 MHz.. THE DEFAULT LOW FUSE BYTE VALUE IS: 0x64
From the ATtiny2313 datasheet we can see that we need to set CKSEL3 through CKSEL0 to be between 1000-1111 (binary). And the exact value depends on the speed we want to run at.
3. Refer to the second table and choose a clock speed.
For an 8+MHz clock speed we want CKSEL3...1 to be 111 and CKSEL0 = 1 for a Crystal oscillator with a fast rising power. Look at the 3rd table to see the changes to the fuse byte. THE NEW FUSE BYTE VALUE IS 0xEF
4. Hook up the Crystal & bootstrap capacitors as shown in the schematic.
5, Program in the new LOW fuse byte by typing into AVRdude the following command:
avrdude -c usbtiny -p t2313 -U lfuse:w:0xEF:m
The ATtiny2313 should now run on an external crystal. Woo-HOO!!!
Step 22: Water the Plants: Design
The first subsystem designed for this project was an indoor plant watering system.
The implementation for this system is straight forward and relatively simple as can be seen in the block diagram given in the pictures.
The activation signal comes from either the DTMF decoder circuit or from a push button.
Materials to Build:
Step 23: 555 Timer:
t = 1.1*R*C
Where t is time in seconds, R is resistance in Ohms, and C is capacitance in Farads. The resistor and Capacitor to worry about changing the values on are the ones that attach to pins 6 and 7 of the 555 timer.
To vary the time within known limits, the resistor can be replaced with a potentiometer acting as a rheostat. This allows for simple changes to the pulse length to be made without having to take the system apart.
The 555 timer circuit requires a low activation signal to turn on. The software for the remote access system was coded to output a high pulse as an activation signal. To reverse the logic fed from the microprocessor to work with the 555 timer, a 3904 NPN transistor was used to short the 555 timer trigger line to ground.
I highly recommend taking the time to read the doctronicswriteup on 555s they have just about everything you would like to know about them.
Step 24: Driving a Solenoid:
The thing you should know about driving a solenoid or a relay or an inductor of any kind is that they have the potential to damage your system if driven incorrectly.
The reason behind this is the solenoid is made from a coil of wire which will form a magnetic field when current is flowed through it. When you try and turn off this current the solenoid will throw a fit. Inductors don't like changes in current, so the inductor will try and keep the current flowing by releasing all the energy stored in it's built up magnetic field to do so.
However, inductors do not care about Voltage and will do whatever they can to the Voltage across their coils to keep the current flowing while the magnetic field is collapsing. This leads to the voltage spiking to extremely high values, a few hundred volts is not out of the question and is in fact quite common. As you would guess this is not a happy thing to see a few hundred volts on the pin of an integrated circuit and will probably kill it.
Fortunately you can protect your circuit by putting in a reverse biased Zener diode. There is a good Sparkfun tutorial on driving relays and there they use a 1N4148 across the relays terminals. This will also work nicely for our solenoid valve..
Step 25: Choosing a Solenoid Valve alternating current or.
A secondary valve made by EHCOTECH was also chosen for similar operational qualities and it was a little more cost effective. The EHCOTECH valve is also actuated by 12 VDC and is a normally closed valve to prevent water from flowing when not desired. This secondary valve can only withstand 150 psi so although it can be hooked up to a house line it isn’t quite as secure as the ECI valve. This valve will also work for a gravity fed system the one you choose may need pressure in order to work right.
A third option is to use the same diaphram valves that are commonly used on regular outdoor sprinkler systems. These are both cheap, and easy to repair/replace.They are also always available at the local hardware store.
Step 26: Water the Plants: Implementation.
The test solenoid described above was attached to the system’s driving line and the circuit is actuated by applying an external voltage to the input lines. The system was tested with various driving times by changing the value of an internal potentiometer. The 555 system is set for approximately a 5 second run time.
The solenoid valve was tested by connecting it to a submersible water pump. The valve would successfully only water the plants for the predefined period of time, and would remain off even in the absence of power to the system. The second image shows the completed system.
The test results met the required design parameters, and with a slight change in the external mechanical hardware connected to the solenoid valve, the system can be driven from a home water line with no trouble.
Potential improvements include the design and use of a water level meter or soil moisture transducer to provide feedback that would prevent the plant from being over watered. This could also keep the water from overflowing the reservoir tank at the base of the planter box.
Step 27: Open the Curtains: (Prototype CNC Axis)
I will start out by saying this is not the ideal design for this sub-system, I've included links to a better design at the end of this subsystems section, which I also later implemented.
It worked because my curtains were on a pulley system and just needed to move the rope up and down to open and close them. At this point I also really wanted to build a CNC machine but the budget & school time frame only allowed for one to be built.... so I compromised by making a single prototype CNC axis that I could use to open and close the blinds.
There is no point in watering plants if they are going to die from a lack of sunlight. So that is why this was made: opening and closing window shades and curtains.
Materials: around)
12 Vdc Wall Wart
Connector socket that matches wall wart
7805 Voltage Regulator
Step 28: Stepper Motors
Stepper motors have a natural 360 degrees degrees)..
Step 29: More on Stepper Motors above. Unipolar motor can be driven as a Bipolar motor by leaving the two center taps unconnected. Because of this it may be in your best interest to buy a 6 or 8 wire unipolar motor and then have the option of driving it as either a unipolar or bipolar motor.
Step 30: Stepper Motor Electronics above
The block diagram for this subsystem is shown above as well.
Step 31: Lead Screw, Thrust Nut, and Linear Rail
Now being able to control the rotation of a motor precisely, the system can be mechanically converted from this motion into a linear path. first image shows the stepper motor attached to the threaded rod. The coupling nut can also be seen at the far right of the same image..
My window curtains opened with a pull string on a pair of pulleys,.
Step 32: Curtains Code:
The software flow diagram is the first image. The second is the complete schematic.\
A copy of the stepper motor program is included as well and it's in C ‘CurtainStepper.c’ sorry assembly coders, no love this time ;).
Also as can be seen in the schematic”. Pretty much just a couple push buttons and limit switches.
I've also included the hex file so you can just burn this straight to the microcontroller.
Step 33: Open the Curtains: (Prototype CNC Axis) Implemented in the figures above.
A local activation push button in Figure 27.
The stepper motor used for this subsystem is a NEMA size 23 motor and was purchased on e-bay with two other identical units for $30. It has a resolution of 1.8 degrees three Figure 28.
The speed of the stepper motor is kept slow to demonstrate the precision control achieved for both linear and rotational motion. As a result the coupling nut takes about a half hour to traverse the length of the threaded rod. For the demonstration the curtain driver was actuated using the local switches. By modifying my code you can easily make that rod spin faster, and have the coupling nut traverse the length of the rod in 10 or so seconds. electrical and mechanical designs are both sound and can be used with slight modifications for a variety of applications . The curtain driver will also be rebuilt using a DC motor with limit switches and an H-bridge.
When I rebuilt this I used a faulhauber gear motor and a reprap magnetic rotary motor encoder which I believe you can now get from makerbotindustries. A photo-resistor and a real time clock were used to make it a standalone blinds opener, but it also accepts a pulsed input so that I can one day connect it to the main system via a wireless link. The actual implementation is similar to this instructable .
My wife didn't like the idea of this thing opening the front blinds when she was walking by in the morning in a bathrobe. So I've decided it will go in the guest bedroom.... you've been forewarned!
Step 34: Unlock the House With the Phone & RFID
The in Figure 29.
Step 35: Electronic Door Strike
This system originally was designed to use an electronic door lock, but a typical keypad door lock costs over $100 and the budget was nearly spent. Instead of the electronic door handle an electronic door strike was purchased for $30 and can be seen in Figure 30.
An electric door strike has the same functionality as a regular door strike, namely to hold the latch of a door secure. Both an electronic strike and regular door strike are shown above to let you know what I am talking about..
This setup is nice because I can leave my door locked all the time and it will remain secure. When I activate the system though, it will unlock for a predefined period of time.
Step 36: RFID Tag
As another means of actuating the door a passive RFID tag reading module was purchased on e-bay for $4 (Purchased in bulk) and is shown as the black RFID system 555 timer (just as in the plant waterer). The 555 timer drives a solid state relay which powers.
The current system also has a 555 timer operating in monostable mode as described in the plant watering section. This holds the door unlocked for ~5 seconds after a valid tag is read that way you don't have to have the tag read and push on the door at the same time to have it open (which got kind of annoying).
The next version will use a parallax RFID reader which returns the actual tag data instead of just a valid pulse. A micro-controller will then either decide if it's a valid tag or forward the tag info onto a computer which will decided if it's valid or not. This will allow me to log who comes home & when and also signal the computer to update the HVAC system based on who is home.
The parallax reader can be picked up for $20-$35 depending on where you look. Here is another instructable dedicated to Atmel chips and this tag reader. Today instead of the MAX232 I'd use either a FT232 so that I could go straight to USB, or a wireless connection like a Zigbee.
Step 37: Unlock the House With the Phone & RFID: Implemented
The RFID enabled electronic door strike was by far the simplest subsystem to design and build. The major components came in preassembled modules that just required interfacing through the appropriate power and signal controls.
Some modifications are also provided from the manufacturer and can be found online from ebay sellers if you get the same system as I did. system and its output was used to sink current through the terminals of the electronic door strike. A diode was place across the terminals of the strike to prevent current spikes from damaging the strike itself.
The addition of the 555 timer circuit made it easier to unlock and open the door when the user’s hands are full. The completed subsystem is shown in above..
Step 38: RFID Door Strike Installed
The pictures pretty much speak for themselves read the comments on them to get the gist of it. This allows me to leave my door locked all the time, I've only had to use my key once or twice in the past few years to open the door during a power outage.
The first image is tilted sideways, but it shows the system installed out of view inside of a cupboard which is just inside of my garage door.
Make one and your wife will think you're the greatest thing since sliced bread... and I mean who's to argue with that logic. You are!
Step 39: Additional Subsystems: Security
Using the items in the above picture we will make a simple yet effective security system that can tell use when and what doors/windows are unlocked or open and it will even work when the power is out!
Materials:
9V rechargeable battery
9V battery charger
Magnetic reed switch for all doors/windows
LEDs
Resistors (various values
Microcontroller (optional)
Wire
Step 40: Additional Subsystems: Security
Choosing a charger & battery :
For this step you will need to decide on an adequate battery and charger system. The battery will be plugged into the charger ALL THE TIME and I mean for YEARS! So you will need to choose a charger that has adequate power delivery to power each LED in the system, but has protection built in so that your battery doesn't explode and catch your house on fire. I've seen Ni-CAD work in this design for a long time, but currently I've been using Ni-Mh.
The CHARGER terminals will actually be the power supply for the system 99% of the time, but if power goes out we still want our security system to work. So we leave the battery plugged in and when power goes out the battery is now powering the system. Even after years of use a battery will typically be able to power a few LEDs for a good long while waiting for the power to come back on.
Step 41: Additional Subsystems: Security
The circuit is a basic flashlight circuit but on a bigger scale.
The charger supplies power to an LED through a magnetic reed switch (switch turns on and off in the presence/ absence of a magnet). The magnetic reed switch is hooked up so that when a door or window is open the LED will come on. Alternatively as mentioned you can have the output not light the LED and instead have it signal a micro-controller of it's status and let the uC decide what to do about it.
To hook up the system:
1. Choose an inconspicuous place to put the charger and battery. Low traffic areas are best as you will want to leave it on all the time.
2. Mount the reed switches on your doors/ windows/ garage door etc.
3. Mount the LEDs somewhere that looks good. I would suggest using the type of LED mount I included as an image, and they look best when installed in a standard light switch plate just below the switch. (Don't get shocked when removing the plate, turn off the breaker first.)
4. Make the following connections with wire
a. From the positive (+) terminal of the battery/charger to the NO (Normally Open) terminal of the reed switch
b. From the the COM (common) terminal of the reed switch to the long leg of the LED and/or micro-controller input.
c. From the short leg of the LED through a resistor and back to the negative (-) battery terminal
You may not need the resistor depending on how long your wires are run. The wire resistance may be enough to protect the LED itself from drawing too much current. To calculate what resistor you need or if you need one use the following formula:
(V-Vfd) / I = R
Where V = 9V, Vfd is the forward voltage drop of the LED (~1.2-3V typically), I is the desired LED current (10-15mA), and R is the combined resistance of the wire and resistor. Using the larger of the values I gave here we'd have:
(9-3) / 0.015 = 400 Ohms
So the combined resistance of your wire and resistor would need to be ~400 Ohms
If you feed the input into a micro-controller be sure you aren't going to have the micro pull too much either, use a 1k resistor between the wire and the microcontroller pin. LEDs are cheap, popping micro's can get expensive.
Step 42: Additional Subsystems: Security
To check if your deadbolts are locked embed a roller switch at the back of the hole your deadbolt pathway. If you get it just right the bolt will still fully close and just turn off the switch. As soon as the deadbolt is unlocked the switch will be depressed and turn on the LED or signal to the microcontroller what state it is in.
The images I've included have some rolled up paper wedging the switch to be in just the right spot. These have held steady for years.
This will require the NO (normally open) and COM (common) terminal on the roller switch to be used just as it was with the magnetic reed switch.
The next step is a micro-controller board you can use as an alternate interface to either a PC or with a standard TV remote that uses the RC5 IR standard. This is a great board to send these door and window signals too.
Step 43: Updating the System: IR User Interface
Here is a board I made to receive RC5 IR commands from a standard universal TV remote. With this interfaced to the other systems I could activate everything without having to leave my couch. This will use a 38 kHz IR demodulator and an ATMega8 microcontroller to do most of the leg work. Here is a parts list:
Materials :
Copper Clad board (perfboard will work too)
7805 Voltage Regulator
1N4001 diode
100uF Cap
0.1uF Cap
22pF Cap x2
10uF Cap x2
10k Resistor
100 Resistor
Push button Switch
1N914 Diode
6 pin two row male header pins
Female header socket or screwterminals.
ATMega8/88/168/328 (Code is for the Mega8 but it is easy to port it over to the others)
38kHz IR reciever
The schematic and board files were done in cadsofts free version of eagle and I believe I got most of the parts from using Sparkfuns library since they are kind enough to let us use these. Thanks Sparkfun!
I've also taken many parts from other places and made a "package type" library (quicker to prototype when I have a new part I may not use again or when I don't want to make a new part in eagles editor). I don't think any of them are in this design but If you come across any let me know and I'll hunt down the parts I used.
Step 44: Updating the System: IR User Interface Board
The next step is to actually build the RC5 IR board. Circuits usually look better when you don't point-to-point solder them (as I've been doing up until this point) unless you've got mad skills .
There are several options for getting a nice looking PCB, you can go to a fab house, chemically etch the board (this method alone has lots of options ). Personally for small batches or one-of's I prefer to mill out a PCB using the eagle plugin PCBgcode on my homemade CNC machine. (Working on a second, for PCBs only CNC, that will probably be my next instructable since I'm taking lots of pics). This way I don't have to deal with chemicals, or laboriously drill holes by hand either.
If you're setup with a CNC:
1. Download Eagle
2. Download PCBgcode
3. Setup PCBgcode to match your machine specs
4. Open my RC5 eagle board layout file which was available in the last step.
5. Run the PCBgcode URL to spit out code specific to your CNCs setup
6. Lay some copper clad boardFLAT to your cutting bit (I prefer a vacuum table that I painstakingly leveled but there are lots of options)
7. Mill out your PCB
8. Drill your PCB
9. Clean the PCB copper with some sandpaper
10. Prepare to solder.
.... gonna have to make an instructable on this process... The links given above should give you most everything you need until I can get one up though. Ask if you haven any questions this alone is a big subject.
Step 45: Updating the System: IR User Interface Soldered
Solder it together:
I used single sided copper clad for this board instead of double-sided so I had to jumper some wires. I would suggest always soldering in an IC socket instead of soldering the IC directly. This both protects the IC from being damaged from overheating and allows you to swap out the IC for another if you decide to upgrade it later.
Some Liquid Tin would keep the bottom nice and shiny looking, as well as make it a bit easier to solder
I hope the pictures can speak for them selves about the jumpers I made, if not, let me know and I'll give a bit more detail.
Step 46: Updating the System: IR User Interface Software
I admit I am not the greatest of coders and would not have half this project built if it weren't for the contributions of may other people. Newton said that he only saw further then other men because he stood on the shoulders of giants. Here are the giants that held me up for the coding on this project:
Peter Fluery : RC5 Decode
Nate Siedel : UART
Joerg Wunsch: iocompat.h
Thanks for all the example code you guys all give back to the community!
I've left a picture of the universal remote that I used for this project, the code contains the hex values for each button press of this remote. Just put in a switch or elseif statment to determine which buttons were pressed and your microcontroller has just gained about 40 inputs! Make them control any of the described sub-systems directly, or feed the input to a computer over the UART through a FT232 (serial to USB converter) and let it decide what to do with them.
Step 47: Updates: Wireless Triggering & Subsystem Addressing
We don't want to have to run wire everywhere throughout the house to sense if an event occurred. Instead we'll transmit the commands and statuses using some Zigbee radios. This is particularly nice because professional home automation systems, such as Control 4, use these already which should make it easy to interface them with our own custom systems.
A huge collection of data on using these things is available from ladyada's site . She also uses these in her tweet-a-watts which as you probably guessed will be heading the way of this instructable in the future.
Sparkfun also has some cheap 434 MHz transmitters and receivers that look like they could work well pretty easily.
Step 48: Automatic Triggers & Computer Interface
Lots of the features of this automation system would be nicer if the user could could configure them on the fly without having to reflash a chip. That's where software like the HAL 2000 stuff typically comes in. Or you can just code your own. If you've never coded a GUI before I would highly suggest picking up C#. As my signals professor used to say "SoooOOOOooo Eeeaaasssssyyyy !!!"
You can get C# for free here.
I'm working on a GUI for this in my spare time now, but you'll have to wait for that. In the mean time you can check out this serial terminal made by Noah Coad that I'm basing my UI on: (He gives permission at his site for use of all his code commercial or other wise. Thanks Noah!)
Basically using the RC5 board as the final interface to the computer, we can take the DTMF signals, pipe them through the RC5 Decoder board, and send them up to the PC. The PC can hold all the special data like valid DTMF codes, or vital decisions to make such as if the garage has been open for a half hour or longer to automatically close it. Sending it's data back down through the serial port the RC5 can transmit wireless data to the appropriate subsystem. This GUI also makes it so you can trigger everything by remote desk-topping into your home computer.
This will be added sometime after I get done with this semester, but the preliminaries are looking promising.
The microprocessor subsystem described before can also enter a lockdown mode if repeated failed attempts are made at guessing the correct code by an unauthorized user. This lockdown mode would temporarily disable the system for a period of time to discourage unwanted users from repeated attempts at accessing various features of the system (like unlocking your front door). This is an example of functionality that will be moved to the computer from the subsystems.
Step 49: Repurposing the System: GPS Car Tracking
It sounds like a big step to change a home automation system to a GPS car tracker... but really it's not. Small tweaks to the system and you can follow your car wherever it goes.
This.
Figure 34: GPS Car Tracker Block Diagram
The block diagram for the GPS car tracker can be seen in in Figure 34. Figure 35 illustrates this process.
Figure 35: GPS Car Tracker Software Flow Chart Figure 36.
Figure 36: Robo-Magellan Robot
The only component that hasn’t been built is the DTMF encoder circuit but there are many chips available for just such a thing (Like the HT9200 ). (the sure dont cost that now) and obtained from Sparkfun Electronics . Figure 37 is a photograph of the GPS receiver and the digital compass being used on the Robo-Magellan robot.
Figure 37: GPS Receiver and HMC6352 Digital Compass on.
Step 50: Final Words
I've got more details on the build and other projects I've worked on at my website . It's quite old though I haven't updated it in years, and the time before that last update was a few years as well so I've got plenty more to post here to the wider community... now if I can only find more time.
I've tried to give all credit to people that inspired or helped this project along in any way. If you think I've left anybody out let me know and I'll gladly add them.
If you liked this instructable please vote for it in the 3rd Epilog Challenge and in the Makerbot Challenge.
If I were to win the laser engraver and after engraving everything I could fit inside the machine I would be most immediately excited about using it to cut out solder stencils for surface mount soldering, making custom engravings on knife handles for the boys in my scout troop, cutting out gears, making project enclosures, bootstrapping a business.... to tell the truth I'm not sure what I wouldn't do with a laser engraver... okay so hottubbing is right out !
If I were to win the Makerbot, I would probably download and print half of Thingiverse . Then I'd look into purchasing a copy of David Laser Scanner and printing out my head to replace those pommels that are at the bottom of stairway banisters. Then I'd see about making a 3d puzzle of a brain based on the scans taken from an MRI.
I can't shake the feeling that I'm leaving something out of this instructable..... So here a picture of an Arduino.... you know just for blog cred ;)
Good Luck all it was fun!
I like this
Wow!... You made a lot of "projects" inside one project!... tks for sharing it...
Something like this? -
Using a program called Team Viewer, I can access my system anywhere there's an internet connection.
man, it´s like instructables.rar
lots of data, seems interesting, i´ll process it slowly and post outcomes
thanks
man i lost my mind here!.....hard to follow you anyway....hahaha
lol.... when I read your post I took the "ha ha ha" as some kind of maniacal laughter and I thought:
"YES! I've finally broke someone with logic!"
Thanks for the post! made my day.
lol......I thank you....maybe some day will provide your help to make my own smart system
What model electric door strike did you use?
It was just some generic electronic strike I found on ebay for $30 a few years back. Ebay member ID I think was KAWALock. Here is one they have for sale now 7 or so years later:
What an absolute "cracker" of a circuit,congrats Dathomar, a very meticulously presented instuctable,superb.
Awesome job! I love how thorough you are on the details :D
Thanks! I tried to put in everything most people would need, but actually cut a lot from what I have so as to leave it general. I'd like to add more updates as time permits though.
Outstanding! This is just what I was looking for. BobbadOut is right: You are thorough!
Ditto squared!!