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.
Concept
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.
GPIO
I am using the following Pins: GPIO23(socket 1), GPIO25(socket 2), P1-02 for 5volt power supply and P1-06 for ground.
Wiring
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:
Programming
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:
/etc/sudoers:
www-data ALL=NOPASSWD:/usr/local/bin/gpio
You can find all the sources of this project on my github.
###
Final Words
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!!