My plan was to control some power outlets(16 ampere) using any browser(for example with a mobile phone). I wanted to use electronics only and tried to avoid relays.
I installed a Debian on my Raspberry Pi(including XBMC aka Kodi) on which a lighthttpd-daemon is running. This Webserver is calling a cgi-script(perl) which enables or disables the power sockets via it's GPIO-Pins. To make it as easy as possible I just call the gpio-command from the WiringPi-Project. I really love to make things work automagically. That's why I also included a function for enabling or disabling a socket at a specific time. Since I kept everything as simple as possible I just used a simple at-job for this.
I am using the following Pins: GPIO23(socket 1), GPIO25(socket 2), P1-02 for 5volt power supply and P1-06 for ground.
The most difficult thing was the wiring. As I already mentioned, I really wanted to avoid relays. Therefore I created this circuit: the GPIO-Pin controls an optocoppler(MOC3041) limited by a transistor(BC547). The optocoppler itself is switching a TRIAC(BT 139). The TRIAC enables or disables the power socket.
That's the circuit:
...and that's how it looks like:
The Website is very very simple and looks like this:
..very basic, isn't it?
Don't forget to change the sudo-rights for www-data:
You can find all the sources of this project on my github.
This project was a lot of fun. I got much support at the Meta Lab(The very best hacker-space in vienna), The project works very well. I also implemented some (green)diodes for indicating if the sockets are enabled or not. And don't forget that I really installed a full xbmc-system. That's why my sockets are also a full multimedia center!!