Simple Home Automation

Right time for my first real blog post... And its going to be about a little project I made to control the lights in my room from my PC over the parallel port! I've been thinking about this for awhile now and today I finally got round to doing it, quite simple in theory really: connect a suitable relay in series with your lights, connect it you the parallel port and write a simple application to flip a bit on the port thus turning the lights on and off! Smile

 

OK so for starters I scratched around in my box of components and found a 12V DPST, 240V AC 5A relay! perfect for turning the lights on and off. Now firstly the parallel port is only capable of about 2mA @ 5v SOOO usually to switch the relay I'd have used a small transistor but I decided to go for a 4n33 optocoupler (http://pdf1.alldatasheet.com/datasheet-pdf/view/250132/VISAY/4N33.html) instead as this would allow us to not only switch the 12V needed by the relay but also optically separate the port from the rest of the circuit, should anything go wrong! Here is a pic of the relay all wired up with the optocoupler hot glued on the side. there is also a small 470ohm resistor inside the heat-shrink near my thumb to prevent the 4n33 from drawing to much current from the port and damaging it!

I tried to keep everything well insulated since we are going to be working with mains here!

Next the port: I didn't have a spare lpt cable lying around so I'm just using my LED test cable atm (It has 8 leds connected to the first 8 bits of the port, I just disconnected the first bit and connected it to the relay for the mean time before I come up with a more permanent solution :) I'm not going to go into more detail about this here, If you want to read up about it I suggest you check out this GREAT article by Levent Saltuklaroglu @ CodeProject.com

 

 

-don't ask about the purple paint on my thumb :P-

Now for Power: the relay needs 12v to activate its coil, hmm where to get that? AH what luck! your PC's outputs 12v on the molex's amongst other places SO I re-purposed a molex pass-through to 12V fan adaptor to power my relay, I also made it easily detachable should I want to disconnect it. :)

 

 

Now for the switch wiring: I connected two decent pieces of wire onto the relays normally closed pole and centre pole (this means the lights will be on by 'default' unless the parallel port pin goes high (or 1) and activates the relay turning the lights off)

 

-Disassembled the switch-

Obviously for the next step your going to want to get a decent torch ready and turn the power off at the distribution board. I made a point of connecting the LOAD to the centre pin of the relay and not the LIVE wire so that the unused exposed pole of the relay doesn't get 'hot' when the relay switches the lights off and risk a short inside the switch!! Its small things like this that keep these simple mods reasonably safe! :)

 

-Attached for testing, sorry for shitty pic.-

AH! and she works! Cool Note I left the light dimmer attach as well so I can still manually adjust brightness and turn them off if needed! Now to put the switch back together nicely!

 

 

I haven't thought of a nice cable management solution just yet but I am quite happy to have a couple wires lying around for the advantages I get!

The Software: I wrote a super simple C# application for testing that uses the freely available inpout32.dll to control the port, again I'm not going to go into detail here since there is tonnes of info available on Google and if you want the basic info on controlling the port I'm going to send you here again Tongue out So this is what the app looks like atm:

 

 

 

And now for a vid of the action! :)

 

If anyone is interested in the app or the sauce (YUM! :P) post a comment here and I'll upload it! Once I get some more time I'm going to write a much better app that can turn on/off at certain times, be controlled over my network from another PC or the internet!! and even have a small app on my phone so I can turn the lights on/off from my bed!!! And anything else I can think of!

Some other considerations: for those of you that know a thing or two about electronics, yes I should have put a diode across the relay to prevent feedback spikes from damaging the PSU, but I'm fairly confident that such a small relay wont be a problem -time will tell!- also I have kept this REALLY simple, I am planning alot of future upgrades like controlling other devices, RS-232 or USB control, and possibly even implementing a Triac to dim the lights from the computer!!! add a couple of sensors and you could be looking at 'SMART' lighting that would dim to the right level depending on ambient light, whether your in the room or not, etc.

Right well that's it for now!

Rob~

Discalmer: This project deals with mains that can injure or KILL, so we cannot be responsible to you or your property if you attempt this bla bla etc. so be careful out there kids! :)

Tags: , , ,

Comments

Joshua Santiago
Joshua Santiago United States
11/7/2009 9:19:09 PM Permalink

That is awesome! Bringing laziness to a whole new level! I would so use that. Laughing +1 awesome

Bredbånd
Bredbånd United States
1/8/2010 10:22:55 AM Permalink

I admit, I have not been on this webpage in a long time... however it was another joy to see It is such an important topic and ignored by so many, even professionals. I thank you to help making people more aware of possible issues.
Great stuff as usual...

workers compensation audit
workers compensation audit United States
1/15/2010 6:59:53 PM Permalink

Nice information, many thanks to the author. It is incomprehensible to me now, but in general, the usefulness and significance is overwhelming. Thanks again and good luck!

payday loans
payday loans United States
1/18/2010 11:54:04 PM Permalink

The hand that follows intellect can achieve.

dr britt borden md
dr britt borden md United States
1/23/2010 9:55:43 PM Permalink

I was wondering what is up with that weird gravatar??? I know 5am is early and I'm not looking my best at that hour, but I hope I don't look like this! I might however make that face if I'm asked to do 100 pushups. lol

free business cards
free business cards United States
1/25/2010 6:24:19 PM Permalink

Just wanted to give you a shout from the valley of the sun, great information. Much appreciated.

IT contractor accountant
IT contractor accountant United States
1/31/2010 7:27:14 AM Permalink

Me and my friend were arguing about an issue similar to this! Now I know that I was right. lol! Thanks for the information you post.

This is such a great resource that you are providing and you give it away for free. I love seeing websites that understand the value of providing a quality resource for free. It is the old what goes around comes around routine. Did you acquired lots of links and I see lots of trackbacks??

Loans in WA
Loans in WA United States
2/2/2010 4:16:26 PM Permalink

All successful people men and women are big dreamers. They imagine what their future could be, ideal in every respect, and then they work every day toward their distant vision, that goal or purpose.

seo consultant
seo consultant United States
2/6/2010 7:33:35 AM Permalink

Hey - nice blog, just looking around some blogs, seems a pretty nice platform you are using. I'm currently using Wordpress for a few of my sites but looking to change one of them over to a platform similar to yours as a trial run. Anything in particular you would recommend about it?

natural insomnia cures
natural insomnia cures United States
2/9/2010 3:16:57 PM Permalink

Pretty good post. I just stumbled upon your blog and wanted to say that I have really enjoyed reading your blog posts. Any way I'll be subscribing to your feed and I hope you post again soon.

When I originally commented I clicked the "Notify me when new comments are added" checkbox and now each time a comment is added I get four emails with the same comment.
Is there any way you can remove me from that service?
Thanks!

polycom video conferencing
polycom video conferencing United States
2/14/2010 3:10:18 PM Permalink

Hi. this is kind of an "unconventional" question , but have other visitors asked you how get the menu bar to look like you've got it? I also have a blog and am really looking to alter around the theme, however am scared to death to mess with it for fear of the search engines punishing me. I am very new to all of this ...so i am just not positive exactly how to try to to it all yet. I'll just keep working on it one day at a time.

yard machine snowblower
yard machine snowblower United States
2/15/2010 10:55:38 AM Permalink

I must say that overall I am really impressed with this blog.It is easy to see that you are passionate about your writing. If only I had your writing ability I look forward to more updates and will be returning.

cialis
cialis United States
2/16/2010 11:56:02 PM Permalink

CIALIS (tadalafil) Online : It's not an accident that while looking for the best Cialis deal you've been led here. It's all because you'll find very low prices on Cialis on our website.

love calculator
love calculator United States
2/22/2010 1:13:44 AM Permalink

Hi, I was browsing the web  and I came across your site. Keep up the good work.

Riaan Deyzel
Riaan Deyzel South Africa
2/24/2010 12:04:39 PM Permalink

Good day

Please send me the source code for this awesome Project.

Thank you & regards

Fat Burning Furnace
Fat Burning Furnace United States
2/26/2010 9:47:15 PM Permalink

Took me time to read all the comments, but I really enjoyed the article. It proved to be Very helpful to me and I am sure to all the commenters here! It's always nice when you can not only be informed, but also entertained! I'm sure you had fun writing this article.

Howdy, i read your blog occasionally and i own a similar one and i was just wondering if you get a lot of spam comments? If so how do you prevent it, any plugin or anything you can advise? I get so much lately it's driving me mad so any assistance is very much appreciated.

buy guitar
buy guitar United States
3/3/2010 3:40:08 AM Permalink

I admit, I have not been on this webpage in a long time... however it was another joy to see It is such an important topic and ignored by so many, even professionals. I thank you to help making people more aware of possible issues.
Great stuff as usual...

roulette systems
roulette systems United States
3/3/2010 11:28:28 PM Permalink

Great post! I am just starting out in community management/marketing media and trying to learn how to do it well - resources like this article are incredibly helpful. As our company is based in the US, it?s all a bit new to us. The example above is something that I worry about as well, how to show your own genuine enthusiasm and share the fact that your product is useful in that case.

You got a really useful blog I have been here reading for about an hour. I am a newbie and your success is very much an inspiration for me.

boards
boards United States
3/6/2010 10:45:49 AM Permalink

I have recently started using the blogengine.net and I having some problems here? in your blog you stated that we need to enable write permissions on the App_Data folder...unfortunately I don't understand how to enable it.

Thanks a lot for the information. I have been searching for this for awhile with Bing and it has been a real chore.

cheap supplements
cheap supplements United States
3/9/2010 2:51:17 AM Permalink

While this subject can be very touchy for most people, my opinion is that there has to be a middle or common ground that we all can find. I do appreciate that youve added relevant and intelligent commentary here though. Thank you!

Add comment




  Country flag

biuquote
  • Comment
  • Preview
Loading