In a world of increasingly intrusive technologies, one sector hasn't quite wiggled its way into our beloved hive-mind. That sector, ladies and gentlemen, is laundry.
Where would we stand as humans in the 21st century without the ability to feverishly check the status of the things we hold closest to our naked bodies - our clothes - while they tumble round and round in seemingly endless ecstasy? How could we live, unsure of the availability of a washer or dryer for our wet and dirty garments, longing for redemption?
It is with great pleasure that I give to the world: open source Internet Laundry.
Step 1: Materials
- 2 - AC Optocouplers (Lite-On LTV-418H)
- 1 - 56K Ohm Resistor
- 1 - 560 Ohm Resistor
- 1 - 1uF capacitor
- 1 - perf board (prototyping circuit board)
- 1 - Raspberry Pi + accessories (power, ethernet, SD card)
- a length of 4-conductor cable.
- 1 - 3 pin 0.1" female header
- Soldering Iron
- Wire Strippers
- Volt Meter
Step 2: Circuit Description
Optocouplers are a great way to isolate two circuits from one another. They operate by powering an LED in close proximity to a phototransistor. You can think of a phototransistor as a BJT with an optically-coupled base. Usually both LED and phototransistor are fabricated on the same die. Some optocouplers, like the one I used, have bi-directional inputs (two back-to-back LEDs).
Here, I used my washing machine's "Door Locked" status LED voltage to optically toggle a pin on my raspberry pi. Since my dryer doesn't have any fancy status LEDs, I used the dryer motor voltage to optically toggle another pin on my raspberry pi. I've included the schematic above.
Step 3: Assemble the Circuit
Grab some perf board or etch your own board, then assemble your circuit. Each circuit should look something like this when you're done.
The big resistor is the 56k that will connect to the dryer motor and the little resistor is the 560 ohm that will connect to the washer LED.
I made two because I have two washers and two dryers. I soldered the male 4-pin header directly to the perf board so that it was easy to connect and disconnect the 4-conductor cable from the optocoupler boards.
There's nothing tricky going on under the board. The two pins to the left of each optocoupler are connected to the holes in the perf board to the left of them. Those two pins are the inputs to the optocoupler. You can see that the ground lead for the washer LED is missing from both the boards at this point.
Step 4: Connect the Washing Machine
The washing machine's LED will want substantially more current than we need to turn on the optocoupler. We'll 'bleed off' or 'steal' only a little current from the LED by putting a (large resistor in series with the optocoupler) in parallel with the washing machine's LED.
I measured the voltage across the washing machine's LED to be 2V DC. If we subtract the forward voltage of the optocoupler's LED (the voltage found across the optocoupler LED when it's in operation) and divide by the operating current (I used 1mA), then we get our resistor value. I'm using a 560 ohm resistor.
Strip a section of wire on the positive and negative connections to the LED, then connect the optocoupler module by soldering on some long wires. Polarity doesn't matter since we're using a bidirectional optocoupler. The two long red wires seen above connect to the inputs of the washer optocoupler.
The 4-conductor cable i'm using is telephone cable. which has red, black, green, and yellow insulated conductors. I accidentally went against the standard and used red and yellow as my ground leads. I'll continue to describe how I wired things together, feel free to swap colors to adhere to the standard.
Connect the black conductor to the collector of the optocoupler and the red conductor to the emitter.
Step 5: Connect the Dryer
DANGER: HIGH VOLTAGE
Make sure you have completely disconnected the dryer from mains power. We will be soldering directly across the dryer motor which is connected to 120-240 VAC mains via the timer switch*.
Since dropping 120 or 240V across an optocoupler's LED will heat it up to the point of thermal destruction due to high currents, we'll need a higher-valued resistor to restrict those currents.
I calculated the resistance to be 120V/1mA = 120k. I didn't have 120K resistors on hand so I used 56K resistors, providing 2mA of optocoupler current. The resistor values are flexible.
Using the schematics for your dryer, identify the two wires that connect to the dryer motor. strip a small section of insulation off of each wire, then solder the resistor to one lead and the other optocoupler input pin to the other. Again, polarity doesn't matter since we're using bidirectional optocouplers (and doubly so, since the signal is AC anyway).
Solder the green wire to the collector of the optocoupler and the yellow wire to the emitter.
If you need to, add insulating tape to prevent any unwanted shorting/arcing.
*this is how my dryer works. your dryer operation may vary.
Step 6: Strain Relief
Tie a knot in the four-conductor cable with enough slack to prevent putting strain on the solder joints.
Feed the cable through a small slot or pre-drilled hole in the washer/dryer's enclosure.
Step 7: Connect to Raspberry Pi
Solder a 1uF capacitor between the green and yellow conductors, then solder two-pin .1" pitch female headers between the (black and red) and (green and yellow) conductors. Now it's as simple as plugging them into the correct GPIO headers and you're done with hardware!
Step 8: Raspberry Pi Software Overview
We'll use the Python programming language to write a web page that will interact with the laundry sensors. It will show which machines are on and off and how long each machine has been running, and it will email users when their laundry is done.
To interface with the Raspberry Pi's GPIO pins, we'll use the Python library available at http://code.google.com/p/raspberry-gpio-python/.
For the web side of things, we'll use the awesome web.py framework (webpy.org). Since this web page will only be used by a few dozen people, we'll use the built-in web.py development server instead of integrating our script with a professional-grade web server like Apache.
The complete source code is just under 100 lines, and is available at https://github.com/dlaw/laundry/.
Step 9: Install the Code
The first step is to install Python and the two libraries we'll need.
Run the following command as root:
apt-get install python python-webpy python-rpi.gpio
Next, download index.html and server.py from https://github.com/dlaw/laundry/.
Put them in the same directory on the Pi, and make sure that you set the executable bits on server.py.
If you don't have two washers and two dryers, you will probably want to modify the device definitions in server.py, and correspondingly update the HTML layout in index.html.
If you would like a more detailed understanding of what's going on in these two files, a great place to start is the web.py tutorial (http://webpy.org/docs/0.3/tutorial).
Finally, we'll configure the Pi to start the server on system startup.
Create a file at /etc/init.d/laundry with the following contents:
case "$1" in
Make sure the executable bit is set. This file tells the system to run /home/pi/laundry/server.py when it starts. The "80" just instructs web.py to run its server on port 80, which is the standard port for web pages.
Enable the startup script by running "update-rc.d laundry defaults" as root.
Step 10: Check Your Laundry. Everywhere.
Point any browser-capable device to the webpage you just set up and you can check how long your clothes have been spinning around. Check your laundry on two monitors at once! Check it on your smart phone! Check it on your friend's computer!
The checkboxes let you select which machines you care about (if there's more than one launderer) and get e-mail notifications when the cleansing is over. You can even check your laundry on your dumb phone by submitting your phone number to the e-mail form according to your service provider's guidelines.
Now go outside and play in the sun!