SparkFun Forums 

Where electronics enthusiasts find answers.

Have questions about a SparkFun product or board? This is the place to be.
By qpwoeir
#11412
Hey,

First off... incredible site! I'm here via digg.com :D

I'm quite interested in controlling one or two house lights over ethernet. E.g. a simple ping to turn on/off (or something like that).

If someone can give me a useful (& safe) guide to do this, you'll get yourself a new customer :lol:

Thanks!!
By Kuroi Kenjin
#11418
I've also been hatching up plans for stuff like this when I get a house (about 7 years or so down the road). Have you heard for X10 power line communication? Although you'd need a "modem" for the wall socket, it's very well documented for that application. Although Ethernet would probably be much cooler and more expandable to control other things.

I myself am still reading up on Ethernet (ever since Microchip came out with their ENC28J60 28pin Ethernet Controller with MAC layer). Olimex is coming out with a breakout board with the externals for this chip actually (which means Sparkfun will probably stock it). You'd probably need this (or similar), a PIC with a decent amount of memor for accessing it and an SPI port (PIC16F876A or any PIC18 should work). Then an appropriately rated relay. Also it may be a good idea to sense the AC voltage so the relay can be switched on the "zero-crossing" to avoid sparking and maintain the relay's life.

As for a guide... I'm pretty sure someone else can help with that.
By busonerd
#11419
A triac + optodiac would be easier.

Also - I'd use an AVR for the controller - much more ram for packet processing / etc.

--David Carne
By Kuroi Kenjin
#11420
True, True. Although many PIC18's are around 2-3.5KB of RAM, but he doesn't really need the RAM since the rather small "ping" packets pretty much stay on the ENC28J60 (if he goes that route).

Nice idea on the Triac!
By Philba
#11422
there is a microchip apnote on building an x10 system. pretty complete with bells and whistles...

however, X10 has it's downsides. the transport is pretty unreliable. Open ended protocol (no receipt acknowledgement).

ethernet (tcp/ip) is a heavyweight protocol - takes a fairly beefy hardware to implement the stack. requires wiring. wifi is fairly expensive and has some reliability issues. echelon has been claiming a very low cost tcp/ip over power lines for some time but has failed to deliver on the promise.

zigbee is looking promising in this area but it's pretty complex. If I were investing some time in this area, I'd look at zigbee - the mesh approach will be more reliable and it's somewhat lighter weight than tcp/ip.

phil
By busonerd
#11425
TCP/IP / UDP/IP are not as hard as people think - I've done quite suprising things with a 20Mhz SX chip [PIC clone] + and an old ISA ethernet controller.

An AVR + one of those RTL8109AS'es or the new microchip part would be pretty damn simple. Also - the amount of work required for parsing non-fragmented UDP is quite low.

--David Carne
By Philba
#11431
I never said it was hard, just takes a lot more than a cheap PIC. we may yet get there. don't forget to include power in your calculations and you have to dump the heat. ethernet devices draw more current than one would think.

What kind of form-factor are we talking about here? I've been assuming replacing a light fixture or prehaps a small box similar to a plug-in X10 module.

I would not use UDP - a reliable protocol makes more sense. when you are putting stuff around 120VAC, you will get lots of noise.

frankly, if you want to just control a couple of lights, the easiest way to go is build an ethernet based box (or use a cheap old PC), create triac based switches that are controlled via wires from the box. You could even set up a simple web interface for the switches.
By qpwoeir
#11433
Hey, thanks for the replies :D

I've looked at x10 before, and as somebody said, it appears very bulky and unreliable. I really like the idea of using ethernet. My idea is as follows:

A very small & simple device with a network interface. The device is placed in the middle of the cable that goes from the light to the switch. When a certain message (e.g. ping?) is recieved on the device's IP, the circuit is closed and the light turns on. Another message opens the circuit and turns off the light.

The device is then connected to a node (e.g. hub) on my LAN and controlled from any computer in the house.

I am however a complete novice when it comes to electronics... so please bear with me :D
By busonerd
#11435
This is probably _not_ the first project you want to try then ;).

Things with 120V are a bad way for a novice to learn... too easy to give yourself a permanent lesson.

Also - ethernet is not the most trivial of electrical inferfaces - unless you go the 10BaseT route /w the Enc28J60 - thats fairly easy.

--David Carne
By Philba
#11436
good advice. 120VAC can be very unforgiving. and mixing 120VAC and digital logic can result in some rather interesting smoke signals. make sure you use isolation,

a simple way to get to embedded ethernet would be to use a prebuilt module like the lantronix xport. rabbit and others have them too. expect to pay in the $50 range. not very cost effective for this application, though. the xport has a driver for the PC that allows you to use a com port to talk to it for getting up and running quick and dirty. also, the xport has several general I/O pins that you can control directly - if you just want on/off control, you don't even need a micro.
User avatar
By phalanx
#11487
Some food for thought...

Microchip has free TCP/IP stacks available for large 18F devices and dsPICs. The 18F stack is set up to use the SPI ethernet controller and the dsPIC stack uses a Realtec ISA bus controller. Both stacks are highly modular and can be adapted to any ethernet controller by modifying the mac.c file included with it. In addition, the stack comes with FTP and HTTP servers with examples on how to create dynamically updateable web pages that show information produced by the controller. The server can also accept data which would allow you to change settings on your board from a remote computer.

I would suggest looking at the dsPIC option. Microchip's C30 compiler is available for free as a student version. After 60 days, you loose the ability to optimize code but other than that, it remains fully functional. If you look at the datasheet for the dsPICdem.net board, you can see how they connected the dsPIC to the Realtec controller.

I've been looking into using the dsPIC stack for a while now as I have a number of ideas for practical applications. I can code in C but I'm no expert by any stretch of the imagination so I've been taking my time trying to read through the code to understand how it works. I could probably get it up and running in not much time but I would prefer to know as much about how the stack works before I do anything. One good thing about microchip is they are very good at documenting their work.

-Bill
By mwrey
#11511
For an open-source tcp/ip stack that supports http you might want to look here http://jalethernet.com/je_index.html it is implemented in JAL (easy to use pascal-basic type language, works on an 18F452 and currently supports either the EDTP packet whacker or a board available from www.voti.nl and the AIR-DROP board from EDTP. Bill has also been talking about porting the stack to support the ENC28J60 SPI ethernet chip. I have used this on the Packet Whacker and have successful in turning LED's on/off thru a webpage and retreiving status. I got distracted from the project but will soon be starting it up again