Introduction: Raspberry Pi Home Automation Server

Picture of Raspberry Pi Home Automation Server

The raspberry pi is an amazing little computer for the price. Now that you have a raspberry pi lets put it to work!

A web-server does not require much computing power or disk space. With a little php and occasional python we can tailor the apache web-server to keep track of an whole array of sensors.

Total Cost $54 (plus 2x5V power supplies):

Raspberry pi model B $25: http://www.newark.com/raspberry-pi/raspberry-modb-512m/raspberry-pi-model-b-board/dp/51Y5087?ost=51Y5087

Server .img $10 https://www.tindie.com/products/Paulware/raspberry-pi-home-automation-network/

Temp Sensor $15 https://www.tindie.com/products/Paulware/texting-temperature-sensor

4 gig sd card: $4 http://www.ebay.com/itm/Genuine-Sandisk-MicroSDHC-4G-4GB-Micro-SD-SDHC-Card-4GB-4G-Class-4-Free-Adapter-/371011823604?hash=item56620727f4

Requirements:

You will need a free gmail account in order to send texts or emails when the sensors trigger. Obtain your account from www.gmail.com

Win32DiskImager should be installed on a pc (to write the .img file to a 4gig or larger sd card).

Putty or an equivalent ssh terminal program should be installed on a pc in your network.

A compatible sensor should be ordered from tindie like:

Note: To program a sensor follow this instructable: https://www.instructables.com/id/ProgramESP8266/

Step 1: Theory

  1. The raspberry pi server is connected directly to the router or through a usb wifi adapter.
  2. The router will assign an ip address to the server via dhcp
  3. When the raspberry pi server starts it will create an apache server located at:
    http://192.168.0.X/Paulware where 192.168.0.X is its address assigned by the router
  4. When the raspberry pi server starts it runs /etc/rc.local which runs a python .py program:udpBroadcast.py which sends a message every 1 minute, broadcasting its udp address on the local network. This broadcast will be read by each sensor and that is how the sensors determine where to send their information to.
  5. You can determine the address assigned by the router by looking at your router page, or by connecting the raspberry pi hdmi socket to a home television, attaching keyboard and mouse to pi and typing the command: ifconfig at the line terminal.

Step 2: Configure the Server

In order to send text or emails when the sensor triggers you need to enter the gmail username and password.

To configure your gmail username and password:

  1. With a browser, open http://192.168.0.X/Paulware/configure.php where 192.168.0.X is assigned by your router
  2. Enter your gmail username and password
    Note: Do not use the "@gmail.com" in the username.

Step 3: Configure Gmail So That the Raspberry Pi Will Be Able to Send Emails.

Picture of Configure Gmail So That the Raspberry Pi Will Be Able to Send Emails.

As explained here: https://support.google.com/accounts/answer/6010255, gmail needs to be configured to allow a python program to send email.

Step 4: Add a Sensor to the System

  1. With a browser, open http://192.168.0.X/Paulware where 192.168.0.X is assigned by your router
  2. Add the MAC address for sensor you purchased from tindie, and you have already programmed using this instructable: https://www.instructables.com/id/ProgramESP8266/
  3. Enter the type of the sensor and the action you want to occur when the sensor triggers.
  4. Test the action to check if the correct action will occur when the sensor triggers.

Step 5: To Make Your Home Server Accessible From the Outside Internet

Go to your router configuration page (which is different for different routers)

Port forward port 80 from 192.16.0.X (assigned by router).

Note: This is an optional step. The server will be able to send emails/texts without this step.

Step 6: Using the Wifi Dongle

If you would rather use a wifi dongle than plug directly into the router, you can follow the ada fruit tutorial on wifi setup. https://learn.adafruit.com/adafruits-raspberry-pi-lesson-3-network-setup/setting-up-wifi-with-occidentalis

I usually use putty to get the line terminal they mention in step 2.

Step 7: Make Your Own Sensor.

You can use the init.lua without change.

The sensor.lua should be modified to change the SSID and password to match your local network, and the function readSensor should be modified to read your particular sensor.

The senor.lua file have the sensor wait until the raspberry pi's address is broadcast over udp. When this address is received the sensor will then send its value to the raspberry pi server.

Once your sensor is working, post it at http://www.esp8266automation.com/ for sale and general review by others.

Thanks!

Comments

About This Instructable

8,230views

43favorites

License:

Bio: thanks
More by paulware:433 Nunchuk Receive Motor ControlRemote Control Vehicle Transmitter With Arduino BlocklyArduino 433 Transmit
Add instructable to: