Smart and shiny!
Raspberry Pi Powered Web Switch
To make use of my second Raspberry Pi (first Pi's application to be detailed later!) I chose to try out some simple smart relay techniques. Using an example and inspiration from a great Make published RPi book (Great resource, I found every example useful and fun to try) I decided to use my Pi and Wifi to build a hands free Christmas light set up. Following the timeless ideal of a creative solution to sometimes disproportionate problem I used my Pi to build a web server based remote for our tree's lights.
This project is a modified form of that found in Matt Richardson's RPi book mentioned above, also found at his website (specifically the WebLamp examples). The script used for tree lights modified was gratefully modified from the example found at these sources
Materials (In order of coolness)
Raspberry Pi Model B My first, totally worth the frantic refreshing and wait after pre-order
Power Switch Tail II Such a great tool, makes me feel like an electrician, without trips to the ER
Adafruit T-Cobbler GPIO Breakout I have both the standard and "T", T shape looks cool
Hardware Connection
Pin 25 of RPi/Cobbler to +in of PowerSwitch (controls PSwitch relay)
Ground of RPi/Cobbler to -in of PowerSwitch
Software
I won't repeat all of the great work featured at Matt Richardson's site, except for the alterations I made. The projecct is based around some simple python work using the python Flask extension, which can be used to support a simple webserver and more. The python-based code is separated into multiple scripts; the main python code and a templates directory (the main HTML to be used in creating the Christmas Lights webpage). The modular design makes it easy to modify the webpage for different applications.
By following all of the instructions at these resources you should arrive at a workable Flask-based web server accessible through your Pi's internal IP address or with http://raspberrypi.local for Apple products or Bonjour enabled devices.
I've updated the HTML in the python files to be a little more festive, but this is purely cosmetic.
Additionally, I added a wrapper shell script to my /etc/init.d directory with sudo execution on the Pi and updated the default boot list to include this shell program.
The wrapper shell script includes the following commands:
sudo nohup python /home/pi/WebLamp/weblamp.py &
Note that the home directory may be different based on your Linux distro and configuration.
With these steps and modifications I was able to create a cell phone (or any browser-capable device on the WiFi network, Flask is very forgiving) switch for our lights. My girlfriend loved the functionality, and it added another personal touch to our decorations.
eOrnaments
In addition to the WiFi switch, I added a couple more electronics decorations to our tree.
Is there ever a bad time for a Ping)))?
Incorporating an earlier electronics project, this year we added an electronic advent countdown to the tree.
3 alligator clips clipping...
I made this device from Wicked Device's Day Counter kit. I originally used the kit for a scheduling aid at the office, but liked the idea of an active decoration. The day counter is powered by a micro-usb breakout (huge fan) and an old cell phone charger.
Almost sad to break down the project, it's definitely made us keep the tree up longer this year
No comments:
Post a Comment