Laundry Room Sensors

This post is one in a series of posts relating to my home automation project. My setup is based on the Uber Home Automation instructable by elecetronichamsters, found here.

I wanted to create a way to detect when the washer and dryer were running. The Uber Home Automation instructable has a solution using a mic to detect the machine noise. I found this solution not to be robust enough. With some perfect tuning it might work but I decided to try to use accelerometers instead.


sensor issues

I bought 3-axis sensors on ebay (here) and then ran into an issue. The sensors I bought communicate with the arduino using the I2C bus. The I2C bus is a device network that the arduino is capable of talking to, and it allows you to connect multiple devices to the same 2 pins (clock, SCL and data, SDA). A network of sensors can be created by connecting the clock and data pins, as long as each device has a unique address, and the arduino acts as the I2C master. Using the wiring arduino library, these networks can be programmed. More info on the wiring library can be found here and a good writeup on I2C can be found on the sparkfun website here.

The problem I had was that the sensors I bought were hard coded with the same address. To get around this, I bought a multiplexer (MUX). I still tied the clock pins of the 2 sensors together, but the data pin each got a spot on the MUX. Then, using another digital output on the arduino, I could select which data pin to look at by changing which device was selected on the MUX. The circuit is depicted here:


detecting machine state

After attaching the sensors to the washer and dryer using velcro, I looked at the values for all three axes in the off state. Then I turned each machine on and watched how the sensors responded. The dryer was easier, since it just runs continuously until the clothes are dry. The washer is more complicated because it runs through a series of water filling, spinning and draining. As a result, there is more logic needed to figure out whether the machine is actually off or just in a low motion state. Here is an output graph of a washer cycle:washer data


Looking at the data, it was easy to see enough distinction between on and off on the Y and Z axes. I decided to use both for redundancy. To determine state, I look at the difference between the current reading and the previous reading for each axis. This allows the system to be more robust because its not looking at a specific value for on or off. It will only be triggered by distinct vibration. The end of the cycle shows very little motion.

Because of the different cycles, I decided to use time to figure out whether or not the washer was done or not. Since it never paused for more than a few seconds, I could just wait longer in between measurements and if more than one reading in a row measures off, then I know the machine is actually done. When the sensor detects that a machine has started, it sends a signal to openHAB to change the state of the machine. Then, when it determines the machine is done, it sends another signal. It doesn’t constantly send data during the cycle, because that would create a lot of traffic on the network.


 programming and openHAB

I found a good example program which helped me get the sensors working for this. The program came from this website. My code can be found on github here. I monitor the machine states in openHAB, and created custom graphics for the washer and dryer. I could have just used the standard light bulb icons but those are boring. I also want to add as switch that will send an email notification when a machine is done if the switch is on. I find this node to be useful because our laundry room, like many laundry rooms, is in the basement. It’s not always easy to hear when they are done and it’s nice to be able to check without going downstairs.



Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s