Web Based Automation For Your Home with Raspberry Pi!

The Internet Of Things is the most trending technology today that stands alongside wearables and robotics. It is a very simple concept where devices in our home or wherever they are , have the capability to communicate with each other via the internet.Usually sensors are used with this technology to pass data to the internet. You can imagine  a sensor installed in your garden which uploads data like temperature, humidity, soil purity ,etc to the internet, and this data will be visible to you from anywhere around the world.Or imagine home automation systems connected to the net , which can be used to control appliances in your home like lights, door locks, air conditioning, etc through a web interface or smartphone application. A lot of technologies are being developed around this concept such as independent light-weight  IoT networks, protocols for passing data,etc. Here, I will show you how you can get started on making a raspberry pi home automation system that is web based using normal HTTP protocols.You will be able to control any appliance in your home from anywhere around the world when your done with this Raspberry Pi home automation tutorial.

web based automation for your home with raspberry pi

Raspberry Pi home automation system based on Internet of Things

Required Materials

Hardware :

  1. Raspberry Pi model B with memory card preloaded with an OS.
  2. Bc547 Transistor.
  3. 5V SPDT relay.
  4. 1N4001 diode.
  5. Solder dot prototyping board.
  6. 9V battery
  7. (Optional) WiFi dongle : Edimax EW 7811UN.
  8. USB keyboard.
  9. HDMI monitor.

Software (Programming languages and OS  involved):

  1. PHP.
  2. HTML/CSS.
  3. Python.
  4. Linux/Rasbian.

How Does it Work?

You can consider the whole system to be composed of two parts: Server and Client. Here, the server is the web interface consisting of buttons and UI (User Interface) that will allow you to turn ON/OFF a device.It consists of PHP files, Html files and a .txt file (to store data).The server usually stores information regarding the button press on the page (ON/OFF) on a .txt file.An example of this UI is : DIY Hacking IoT Implementation. This is a simple Html file called main.html ,consisting of two buttons.The clicking of the buttons will trigger the execution of a PHP file called button.php. This program serves as an API (Application Programming Interface) to store data on to a text file called buttonStatus.txt.The data is a string : “ON”, if ON button is clicked and “OFF”, if OFF button is clicked.Thus the current button press state is recorded in the text file : buttonStatus.txt.

diagram web based automation for your home with raspberry pi

Raspberry Pi home automation Block Diagram

The client side consists of a Raspberry Pi with a relay circuit connected to its GPIO pin.The pi runs a python program which is used to ‘Post’ a url link using urllib2.That is, the pi constantly reads the contents of a url link. Here, the url link is another PHP file called buttonStatus.php. This PHP file serves as an API to read the contents of the text file buttonStatus.txt.After reading the data, the python program checks if the string obtained is “ON” / “OFF” based on which it switches ON/OFF the relay respectively via its GPIO pin.

For more detail: Web Based Automation For Your Home with Raspberry Pi!

© 2015 Powered By Engineering Projects Team, Raspberry Pi Projects

Scroll to top