A Remotely Programable Relay Controller (Christmas Lights or Home Automation Controller)

 by drj113
Featured

Step 2: The Hardware

Relay.PNG

The basis for my project was my Arduino Ethernet controller board - I simply connected 6 switched relays of some spare I/O lines, and designed a new PCB layout because I enjoy the quiet Zen state when I am laying out a new PCB.

There is nothing stopping you from putting a set of relays onto a piece of stripboard, and running them from an Arduino board with an Ethernet shield.  The only caveat is that the Ethernet shield has to be based on the ENC28J60 chipset.  That is what I support in my code.

Here is the circuit diagram of one of the relay outputs.  You can see that each relay is driven using a BC547 transistor.  There is nothing fancy about the BC547 (except that they cost about $0.03 in quantity)  you can use whatever type of NPN switching transistor you like.  There is a current limiting resistor between the base of the switching transistor and the Arduino output to protect the transistor from damage.  There is also a spike protection diode across the transistor to protect it from the large electrical spike that occurs when the relay is switched off.  There is also a LED installed so that you can visually see the state of the outputs.

You will also find the full schematic diagram for the project here as a PDF.  For more information, have a look at my Ethernet Arduino Instructable.

Update - It was suggested that the protection diodes should be placed straight across the relay - so I have amended the pcb layout, as well as fixed the schematic.  Thanks for that!

 
Remove these adsRemove these ads by Signing Up
mantux100 says: Dec 22, 2010. 8:11 AM
on schematic you wrote that the controler is Atmega8 and on parts list you write that it's AtMega 328 and that gate ic is 74ls08 but on pats list you write 74HC08 . WTF????
drj113 (author) in reply to mantux100Dec 22, 2010. 12:18 PM
The parts list is definitive. The Micro is definitely an AtMega328, and the gate is a HC part.
shaadmahmud in reply to drj113Nov 21, 2012. 1:20 AM
can i use mega168 instead of mega328?
abishur says: Aug 9, 2011. 2:39 PM
So do I have to have an Arduino to program the main chip or is there another method for programming it? I know they're not too expensive, but I'd prefer a bit of a cheaper option
diy_bloke in reply to abishurApr 20, 2012. 4:21 AM
probably a bit late for you, but if someone else has that same question:

On the Arduino.cc website there is a link for a parallel port programmer that does not ask much more than a subd 25 connector and some resistors.

For sending programs to the bootlaoded chip, consider serial upload:
http://arduinodiy.wordpress.com/2012/03/19/serial-connection-for-your-arduino-atmega/
drj113 (author) in reply to abishurAug 9, 2011. 5:49 PM
I use a cable from Sparkfun called an FTDI-USB 5V cable.

All of my projects have a 6 pin header that is designed to use this cable to program the chip.

Doug
mantux100 says: Dec 30, 2010. 5:50 AM
What P3 does?
drj113 (author) in reply to mantux100Dec 30, 2010. 11:33 AM
P3 is a spare connector for expansion - One day, I may add an extra set of 6 relays, or provide 6 inputs that is connected via P3.
hightekrednek2396 says: Dec 11, 2010. 5:26 PM
what relay did you use
drj113 (author) in reply to hightekrednek2396Dec 12, 2010. 12:07 PM
I used 12 Volt relays from Jaycar here in Australia.

Here is a the URL:

http://www.jaycar.com.au/productView.asp?ID=SY4050&keywords=relay&form=KEYWORD
hightekrednek2396 in reply to drj113Dec 12, 2010. 3:49 PM
will any relay that has the sepecs of this one work
drj113 (author) in reply to hightekrednek2396Dec 12, 2010. 4:12 PM
Yep - there is nothing special about the relay at all.
Swishercutter says: Sep 4, 2010. 2:36 PM
One slight problem I think I found with your circuit. To get rid of the "inductive kick" you need to place D5 on the relay coil with the cathode on pin 4 and the anode on pin 5. Tested it in Multisim and the configuration you have still has the spikes...the point of the diode is not to shunt to ground but to route the spike back to the coil/voltage source. Also...not that it makes a ton of difference but the way its setup now you have to apply power to keep the relay inactive, if power is a concern (operating on batteries etc.) I would move Q1 so that the +12V was at the collector and Pin 4 on the coil connected to the emitter and Pin 5 on the coil to ground. It works either way...just depends on if you want an active high or an active low from your input.
drj113 (author) in reply to SwishercutterSep 4, 2010. 5:40 PM
Thanks for your post. The idea with the diode makes sense, and agrees with other designs I have seen - I guess I was focused on protecting the transistor like they do with big mosfets (with the diode in the pack...) - I will change the layout in the next day or so.

I am a little confused about your second point - the NP N transistors dont conduct unless there is base drive, so I don't understand your comment?
Swishercutter in reply to drj113Sep 4, 2010. 6:17 PM
Sorry, was reading a point wrong, the second part was completely off base...was thinking in terms of digital inputs...I was envisioning the coil as a digital input with a pullup resistor, in that sense it would give you a logic high when the input was low (I have been working on 555 stuff lately). Completely wrong for a coil I apologize but the first half is still right.
drj113 (author) in reply to SwishercutterSep 4, 2010. 8:47 PM
No worries - I have amended the diagram and PCB layout to cater for the diode changes. Thanks for your input.
Pro

Get More Out of Instructables

Already have an Account?

close

PDF Downloads
As a Pro member, you will gain access to download any Instructable in the PDF format. You also have the ability to customize your PDF download.

Upgrade to Pro today!