Friday, March 6, 2015

Home automation system based on Raspberry pi

After building the Raspberry Pi tablet, i decided to do more, this time something for home automation, and what better thing to automate first than the light system.
For this project i ordered a Raspberry Pi model A. The main difference between model A and model B is that model A doesen't have an RJ45 port and 2 usb, also the ram have been lowered to 256 mb. Becase of this downgrades it is more cheaper, but for an automation project it is perfect.
The idea is to set some ports as output, connect those ports to some optocouplers that acts as a switch for the 12V adpter that power the 12V relays that turn on/off the lights.

In the above picture you can see the optocouplers and the relays soldered on an old pc power supply circuit board.
The relay board and the Raspberry board is fitted inside the power supply metal case for protection

I also wanted to have an touch pannel inside the wall, and for that i decided to use a simple android tablet.The andorid tablet is set to automatically connect to the raspberry via wifi, the light of the display  set to minimum and always on.
The interface that control the relays is called Webiopi which allow you to use HTML codes to create a nice interface for the output ports.

In this image you can see the web interface on the tablet mounted in the wall.
Becase i use webiopi i can switch the light both from any device that can connect to the internet.
I also let the analog switches of the light bulbs, in case something goes wrong with the raspberry board or the relays. Those switches are connected to the relays, so it is possible to turn on the light from the analog switch and turn it off from the touch panel (or any device) and vice versa.
Here is a video with the system in action:

Source code of the HTML file: index.html


  1. Hello, sorry for the delay, the link to the code is now in the description.

  2. Hello , how do you control the light with both the wall switch and the relay , and how the system detect if it on or off , can you show me how you did the connections

  3. hi the link for the code is not avaible
    thank you

  4. Code link is not working :-(

  5. Code link is not working :-(

  6. Hi there. It is really interesting what r u doing. Would you share html code please? The link above doesn't work.
    Thank you

  7. I wondered 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.
    Home Automation in Chennai
    smart home in Chennai
    Home security in Chennai
    Burglar alarm in Chennai
    Door sensors Chennai

  8. This may be my new favorite post. I absolutely love what you did here and if you don't mind, I may be stealing your idea and plans for my own house! I'll have to enlist the help of my brother though, since I don't have the technical prowess that he possesses. Please keep us up-to-date on all your fun experiments!

    Dwayne @ Elite System Design