Mains electricity can KILL. Make sure you learn about safe shielding, connecting and grounding practices.
Above all, be extremely cautious!
I can't stress this enough.
EDIT: For more information: http://tubelab.com/Safety.htm
The usb relay is NOT designed for this! See the picture: http://www.circuitgizmos.com/products/cgu451/cgu451.shtml
In a device intended for hybrid hi/low voltage there is a clear gap between the high and low voltage components, and an isolation transformer or opto-isolator between them.
This is not manufacturing. It's a one-off project. It's not a highly refined design. You don't have to worry about finessing a marginally lower build cost because of what it will mean in 10k unit quantities. Just use the opto-isolator.
An isolation transformer would be of absolutely no use here and the optoisolator would provide the same functionality that the existing relays on that board do.
I can't see how the PC board is laid out so I can't verify if there is inadequate separation between the control side and the isolated side of the relay (even so, you only need about 5mm separation to be minimally safe at 120V), but barring that, it's fine!
Yes, this particular device is not explicitly designed to deal with all the hazards of switching a high voltage load, but I don't see anything that leads me to believe that it's unsafe for that purpose.
But if you do mess around with RasPis or Arduinos for that, I can't stress how useful the PowerSwitchTail is http://www.powerswitchtail.com/Pages/default.aspx - you give it a low power signal, and it switches a high power one. They have a 220v version as well.
In fact if I had the free time then I'd build a binary display for page hits using a series of LEDs on a Raspberry Pi (sadly I have a million other projects going on at the moment - such as finishing my website so I can get hits to begin with hehehe)
Amazingly, I never had a single incident with that parallel port->breadboard+transistors+relays->lights setup from my high school days.
Please use LEDs, don't even bother messing around with opto-isolators and so on unless you have experience with both mains electricity and designing safe circuitry.
- 12v power supply (from like anything in your house)
- 12v LED strip (super cheap on eBay or basically anywhere)
- This awesome MOSFET from Adafruit http://www.adafruit.com/products/355
This is what I used for a cool RPi + RFID + LED project this year, write-up coming eventually, here's a clip for now:
http://vine.co/v/bvZQVJLnemh - my example only has a few LEDs but in the final product I used strips with about 30.
Besides turning on lights, the cool thing about relays is that most things involving physical push-buttons can be taken apart and easily wired up to a relay.
The opportunities to improve current products are so endless that I become overwhelmed whenever I think about this. We all have the parts to do this today, but so few are assembling them.
Want to set an outlet to turn on or off at different times? No need to buy a timer, just goto that outlet's website on your WIFI LAN, and set it on a timer. Or you could depower the outlet to make it child-safe.
Are you going on a trip and you're afraid you left the toaster plugged in and your house might burn down? Just VPN to your home LAN, sign into your kitchen's website and have it power off all outlets.
Locked out of your car? Pull out your phone, securely sign into your car's website, and tell it to unlock the doors.
Power and depower garage door openers, sprinklers, RC cars, even industrial equipment from a simple web interface.
The video halfway down shows it in action.
USB breakout board -> MSP430 -> LEDs/Buzzers/Whatever
You're talking somewhere around $14.
Yes, you'll need to know C or assembly for the MSP430 and likely a scripting language for the PC, but it makes a lot more sense than bringing in all of that horsepower to essentially get an I/O and light an LED.
You can get a small remote power switch for $100 or so.
Edit: $45 on Amazon at present.
That's a very safe way of doing these things. If anyone else knows how I can reverse-engineer the signal, I'd appreciate it (I also want to make the Raspberry Pi open my garage door, same deal).
I don't even know where to start and whether it will be a fruitful exercise (i.e. will I be able to devote sufficient time to it to actually learn something worthwhile).
Anyway, this is a neat project and I wish you good luck OP!
Check out http://Raspberry.io for some resources the python community put together to use Raspberry Pi
Check out makezine for resources designed for people who aren't even familiar with programming. It doesn't take much to get up to speed with some basic on/off circuits. With a little high-school physics or just some asking around of friends you can get custom devices going.
I'm now in the process of abstracting the entire thing into a self-contained box that communicates over wifi and uses mains electricity. Hopefully I don't kill myself.
Maybe iterate it to use LEDs instead of incandescents.
For hardware hacking- you have 3 types of hardware that can make life easy- but there are tradeoffs:
2) Raspberry PI
Arduino is great when you want low power, but it isn't an awesome internet platform.
Raspberry Pi is great when you're going to leverage a full blown PC Monitor, but using it for hardware hacking requires a bit of elbow grease
The Beaglebone is great for when you are doing something internety & hardware hacky, but without a full blown pc monitor.
I would have done your project with a beaglebone, fwiw. I'd also have used LEDs instead of incandescents. But this is a great project! Nice work!
At the time I used MacMini, which was a tiny bit expensive for this very purpose (also not everyone in the office likes a blinking light 24/7) then eventually I came up with the following oneliner:
tail -f "<access_log>" | grep --line-buffered "<whatev>" | sed -ue "s/^.*$/\x07/"
I also needed to set the terminal bell to be a "click" instead of a "bell" for this to sound acceptable during
Peggy's could be fun too: