Step 1: Parts
• Raspberry Pi
• Remote controlled outlets
• Ribbon cable
• PCB board
• Soldering gun
• Wire cutters
• Wire striper
Step 2: Web Server Setup
Connect your R-PI to the internet. Logon to your R-PI and enter the following at the command line:
chmod +x setup-web2py-ubuntu.sh
Follow the instructions on the screen. This step will take several minutes and you may see some errors in the process, but it seems to work anyway. The mail configuration is not really important, you can just set it as “no configuration”. When asked about your location and such, the values aren't critical, do your best. The most important thing is to remember the admin password that you select during the installation
Once the installation is complete you should be able to connect to web2py server from your computer. In your computer's browser enter the address to your Raspberry Pi. It is very important that you used https when connecting to the web2py server. Your URL will look something like:
https://192.168.2.179/ or https://rasberrypi
You may see a security warning in your browser. That's OK, you can safely ignore this warning. If everything worked correctly, you should now see the welcome page for Web2Py.
Step 3: Make the Board
As Dave Jones says, "don't turn it on, take it apart!". Open up the case on your remote control. I hope your's is as easy as mine, it just had 3 screws. Look carefully at the board on your controller and find where the buttons are, most likely they are traces on the PCB activated by rubber button. Follow the traces connected to the button, there should be 2 connections to each button. One side of the button will be connected to a chip on the board (it will either be a black rectangle with legs, or a black plastic blob), the other end will be connected through a resistor to either the battery + or the battery -.
In my case, the buttons were connected to the + of the battery. This means that the button "pulls up" the micrcontroller line to the supply voltage when it is pressed. To emulate the press of a button, we will connect the GPIO of the Raspberry pi through a resistor to the of the button that is connected to the chip on the board (rectangle or blob).
The first schematic shows how the buttons were connected on my remote. The second schematic show how to inject the signal from the Raspberry Pi.
I created a board to make this as small as possible and be able to add the extra hardware into the case for the remote. The layout for the board is included. I used surface mount resistors because I had some, also the values aren't that important, 330 Ohm - 1K Ohms would be good choices. If you have different values and through hole resistors, that's fine, it will work fine. Also, creating a custom board for this is not required, you can certainly solder resistors directly to the remote's board. (good luck :))
Step 4: Connect to the Controller
Use your dremel or file to make a slot in the back of the remote case so that the ribbon cable comes neatly out the back.
Step 5: Connect to the Pi
Step 6: Install App
1. Download the file, and unzip the file.
2. From your web browser (on your pc) connect to the Web2Py server using https. https://raspberrypi/
3. Select Administrative Interface
4. Enter the password that you set when Web2Py was installed
5. Under "Upload and Install Packed Application" enter the application name of "Home_Lights" and select a the "web2py.app.Home_Lights.w2p"
6. Press install.
7. After the application installs you will see the application added to the list.
The application requires you to login to the application, you don't want random people turning on and off you lights! So we must create the users.
1. Under the Home_Lights application press edit.
2.Under Model, press "database administration"
3. Then press the "New Record" button next to db.auth_user
5.Enter First Name, Last Name, Email, and password. All other entries can be ignored. When done press "submit"
You can now navigate to the Home Lights application: http://raspberrypi/Home_Lights and login with your email and password.
Step 7: Setup GPIO Server
Logon to your Raspberry Pi (ssh or at the command line, it doesn't matter) and install 1 python module:
tar zxvf RPi.GPIO-0.4.2a.tar.gz
sudo python setup.py install
With that module installed, the server can be started (must be running for the web application to work)
sudo python /home/www-data/web2py/applications/Home_Lights/modules/GPIOServer.py