Introduction: Laundry Room Monitor

This started as a quick project to provide an alarm and phone notification when a water leak was detected in our second floor laundry room. A couple of years ago the drain hose from the washer somehow came out of the drain and the water made a bit of a mess in the living room below. In a classic case of scope creep (and a reluctance to dedicate an Arduino to just this one task) it ended up as a more comprehensive laundry room monitor that:

  • Does the leak detection and notification
  • Monitors the dryer vent for an over temperature condition
  • Monitors power consumption (and thereby cost) of washer and dryer operation (for each cycle and on a running total basis)
  • Provides notification of washer and dryer cycle completion
  • Provides detailed information on washer and dryer cycle progress
  • Provides a system to notify and record the need to replenish detergent and dryer sheet supplies

All this is implemented with an Arduino, the nifty Blynk app and a variety of sensors. Inspiration for the cycle monitoring came from this Instructable but ultimately I went in a different direction for reasons explained below.

Step 1: Components

Assuming you want all the functionality of the whole project you will need:

  1. An Arduino or similar microcontroller (I used an Arduino Mega). As written, the sketch is a little too big for the Uno and would in any case just about max out all its I/O pins).
  2. Ethernet shield or some other way to connect the Arduino to the interwaves.
  3. A prototyping shield or breadboard. I really liked this prototyping screw shield for its semi-permanent results. You'll probably need a breadboard anyway for early tests even if you don't use one in the final project.
  4. Two current transformers. These are rated up to 30A and have an integrated burden resistor.
  5. One or more water sensors. I used two - one in the drain hose/ supply hookup area and one in the washing machine pan. This may be a bit of overkill since I think water from the hookup area would flow into the pan but for another $5 I figured why not.
  6. DS18B20 Temperature Sensor. This thing was perfect for the dryer vent temperature monitoring.
  7. Some physical momentary switches. This is where I kinda blew the project budget, going for some fairly exotic buttons for purely aesthetic reasons. I used a total of five buttons, including these and these. You actually don't need ANY physical buttons if you are happy to rely on the Blynk app. You certainly could get away with using button switches costing a few cents each.
  8. A blank 2-gang switch plate. I used a stainless steel one again for aesthetic reasons. You can get a plastic one and save yourself two bucks. This would also make it easier to drill the holes for the buttons and LEDs.
  9. Low voltage old work box. To secure the switch plate. You can use a regular old work box and cut the back off it if you happen to have one. An unmodified two-gang box will not work since the Arduino and shields are too big.
  10. Bits and bobs that hopefully you have lying around - LEDs, hookup wire, crimp connectors, resistors (330Ω for the LEDs, 4.7KΩ for the temp sensor, 10KΩ for pullup/pulldowns and voltage divider circuit and a couple of 10uF capacitors).
  11. An enormous plywood school bus, a Raspberry Pi and a radio alarm clock.

All up, well under $100, not including the items in 11 which are optional in every sense of the word, except for those with theatrical tendencies. Still way too much for what it is, unless you actually enjoy doing this stuff. I spent an insane amount of time on the thing, which for the most part was fun. In amortizing cost into fun, it helps greatly if you have no idea what you are doing. So the way I look at it I spent about $90 on many, many hours of entertainment. And got a great Heath-Robinson contraption for free.

For the budget minded, I should perhaps note my first approach to this project was to use vibration-sensing switches to detect washer/dryer operation (the switches replaced the dual-axis accelerometers used in the project I cite in the Intro). This would cut out about $30 of cost and simplify the project quite a lot. But what you lose is all the energy monitoring functionality and the ability to know, within a few seconds, when the washer will finish up. Critical, obviously.

Step 2: Tools and Resources

At a minimum, you'll need:

  • A multimeter, preferably one with a clamp to help calibrate the current readings. A while back, I got this one. Even though I don't use the clamp function much it's proved useful as a second meter for when I lose my other one or I need to take two readings at the same time.
  • Soldering iron
  • Drill and step bit (for the wall plate fabrication)
  • Miscellaneous hand tools (pliers, wire strippers, etc.)

For the current monitoring, I found the OpenEnergyMonitor site very helpful. Not only is there a step-by-step guide for the current monitor itself but the whole site is a valuable window into the world of domestic A/C power. As you will see, it is focused primarily on whole house energy monitoring, and in the UK at that, but I didn't find that undermined its usefulness for this project. There's even a discussion of the differences between U.S. and U.K. supply that goes beyond the usual 240/50 vs 120/60 throwaway.

On a much smaller scale there is a nice YouTube tutorial on using the DS18B20 temperature sensor. Nothing really difficult here but the presentation is a model of clarity (other than what I assume is a typo in the schematic showing a 47KΩ resistor instead of the (correct) 4.7KΩ value).

Last but hardly least is the Blynk site itself. Although I find it sometimes seems to swerve suddenly from the reasonably obvious to the puzzlingly obscure (especially outside of the Arduino world) this is probably my ignorance of basic concepts I have failed to grasp. None of that takes away from the genius of the idea, which makes creating apps for just about any IoT project a snap.

Step 3: Why Current Monitoring?

Before starting this project I considered a variety of ways to monitor the washer and dryer. As already noted, one way is to detect movement, using accelerometers or, more crudely, simple vibration sensing switches. I actually built the first version of this project using the vibration switches. It worked, but was a bit temperamental. It was susceptible to external factors (the switches can be very sensitive, while at the same time occasionally "sticking" in the open or closed position). More importantly, it was virtually impossible to keep track of where the washer was in its cycle -- while filling for wash or rinse it obviously doesn't move. Was it done, or just filling again? I tried to code around this but there were just too many possible scenarios to consider. Monitoring sound would have all these problems and more.

We have a pretty basic washer and dryer with knobs that you turn to start and that actually move during operation. So in theory some system of position monitoring could be devised. However this would require physical modification to the appliances and would not be transferable if we needed to buy a new machine.

This left current sensing and when I stumbled across the OpenEnergyMonitor site it was an easy decision. I was worried that the current used by the washer while filling would be too low to detect (in my simple washer I assume it is powering only very basic electronics) but as it turns out this was not a problem (although I did need to include some code to confirm readings).

Step 4: Build the Main Circuit

Here's a Fritzing sketch of what I ended up with. If you use the prototype screw shield you'll need to focus on the Uno-compatible pins (i.e., digital through 13 and analog through 5) even if using a Mega. All the button inputs are pulled up when open via the Arduino code so no physical pull-up resistors are needed.

Step 5: Build the Current Monitoring Circuit

Here are the instructions for the current monitoring circuit. Obviously you can combine the main circuit and this circuit on one breadboard or on your prototyping shield. I did build them separately because the decision to go with current monitoring rather than vibration sensing came half-way through the project.

You'll need to replicate this circuit for the washer and dryer. Assuming you are using the Uxcell SCT 013-030 current transformers linked in Step 1 you will not need the burden resistor shown here since the 013-030 transformers have an integrated resistor and output a 1V AC signal. However, you do need to modify the DC bias so that it provides 1V rather than the 2.5V mentioned in the instructions. You can do this by substituting the two 10K resistors in the voltage divider with a 10K one for R1 and a 2.5K one for R2 (assuming a 5V supply).

If you study the OpenEnergyMonitor site you will see that they recommend measuring voltage as well as current for greater accuracy. Although not significantly more effort I decided not to bother. For me the power usage info was a nice bonus from my decision to use current as the input for monitoring washer/dryer operation. The dryer is by far the biggest consumer of power (just to be clear, we are talking electric only, not gas/electric dryers here) and, based on my rudimentary understanding of power factor, is largely a resistive load (because most of the power is used to produce heat, not turn the drum). This means the "apparent power" measured by the transformer alone will be pretty close to the "real" or "true" power consumed. As you will see in the code, I used a PF of 95% for the dryer and 85% for the washer (where the total load is largely inductive, assuming it is not heating water). I just made these numbers up. The washer number is probably far too high but I wanted to err on the side of overestimating real power (I think this is the power used for billing purposes, at least for residential customers).

Step 6: Install the Current Transformers

The SCT 013-030 current transformer is a split core design so you can clip it round the washer and dryer supply cords without too much trouble. However, you do need to separate the current-carrying conductors otherwise the current flowing in opposite directions will simply cancel the signal out.


In my case, both the dryer and washer cords were the flat type where the fully insulated cables were visibly separate. So AFTER UNPLUGGING THE CORDS FROM THE OUTLETS, it was very easy to separate the insulated current carrying conductor I wanted to isolate by using a utility knife between the cable channels. If you examine the plug it should be obvious which cables are which. Cutting a few inches at a convenient point between the plug and appliance is all you need to get the transformer clipped around the cable without forcing anything. When you are done cutting, MAKE DOUBLY SURE YOU HAVE NOT CUT INTO OR COMPROMISED THE INSULATION ROUND THE CONDUCTORS.

Your cord may be the round type and have all the cables protected by one external sheathing. As well as being round, your dryer cord may also be of the newer "four wire" type where the neutral and ground are separated. In these cases I'll leave a safe and legal installation up to you, keeping in mind the objective is to safely isolate an INSULATED current carrying conductor for each appliance. Again, IF IN DOUBT, CONSULT A QUALIFIED ELECTRICIAN.

Before proceeding further, you might want to plug the cords back in and check current readings using a clamp meter on the isolated conductor. You can use these readings for initial calibration and insertion into your code.

The current transformers come with a 3.5mm plug on the output. I simply cut this off and used crimp connections to route wire back to the Arduino (the wire from the transformer itself will likely not be long enough for most installations). The cables with the current transformers can then be dropped out-of-sight behind the appliances.

Step 7: Installing Sensors

As I noted in Step 1, I used two water sensors -- one in the washing machine pan and one in the supply/drain area. These need three wires each (for 5V power, ground and signal) that need to be run to the Arduino. The temp sensor needs only two wires (power and ground both go to ground with actual power supplied through the signal wire - see the Fritzing sketch in Step 4). All this plus the wires from the current transformers, power to the Arduino and an ethernet cable means you will have quite a bit of wiring to consider how to route. Every installation will be unique so I will not go into too much detail here. But as you can see from the photo I routed most of my wires through the washer hookup box. The glowing red LED is from one of the water sensors.

I power the Arduino from a USB power supply located in the laundry room which makes updates to the code and access to the serial monitor easily available.

Since the water sensors have male pins, I used female jumper cables for the initial connections which with some heat-shrink tubing made a reasonably secure arrangement. Then it's just a matter of splicing in wire of the appropriate length back to the Arduino. To stop the water sensors moving around I used some self-stick velcro pads with one side stuck to the back of the sensor and the other side stuck on the surface to which each is mounted. For the temperature sensor I simply taped it to the outside of the dryer vent. I did consider inserting it into the vent itself which presumably would give a more accurate reading but in the end didn't bother. There seems to be a very wide margin between normal dryer operating temperatures and an unsafe condition so I think this arrangement would provide plenty of notice an unusual situation was developing. I was also unsure how well the sensor would hold up in the high humidity of the vent exhaust.

For the keenly observant, the "NO" shown in the photo is actually "ON" for the hot water supply but upside down. A quirk of the existing plumbing meant that when I replaced the washer shut-off valves recently it was far easier to install the whole hook-up assembly with the supply at the top rather than the (presumably intended) bottom of the hook-up box. Since "OFF" (on the reverse of the NO/ON lever) still looks like "OFF" but upside down I didn't think this introduced indecipherable ambiguity.

Step 8: Wall Plate Preparation

The layout of the switches and LEDs is a matter of personal preference. The picture reveals a latent anthropomorphism I hadn't noticed in real life. Since I didn't want to clutter up the plate with a lot of words (and didn't have a professional way to label the plate anyway) I wanted it to be as intuitive as possible. The obvious approach was to have washer functions and indicators on the right and the dryer's on the left. This corresponds to the location of the washer and dryer in the room. At great expense I also used a blue button for the water alarm test button and a red one for the dryer vent temperature. Same for the LEDs.

Making the holes for the buttons and LEDs requires a bit of patience, at least in a stainless steel plate. Even though the plate is thin it will challenge a blunt drill. After marking the center of each hole in pencil I used a punch then drilled pilot holes before using a step drill to get the necessary sizes for the buttons. A regular bit will do for the LED holes. Go slow and use cutting oil! Even then you may have to de-burr with a Dremel. If you have a drill press, that would be good.

The switches themselves are easy to secure using the included hardware. The LEDs are a bit more tricky to attach. I used some small rubber grommets with a hole a bit smaller than the LED. These I glued to the back of the plate then pushed the LED through after applying a bit more glue to the LED flange. Hopefully this will be more robust than simply gluing the LED directly to the plate. It also has the benefit of having the LED not protrude too far out of the plate.

The top two buttons with the integrated "angel eye" LEDs were originally to be used to manually start the washer/dryer monitoring. Because the current detection is highly reliable, monitoring now starts automatically (much better, since I know my family would never press a button to start the system). This meant I needed to find another use for the buttons. Pressing both together now resets all the code that tracks where in the cycle the washer is and zeros out the cost and timer displays (but not the running total displays). This might be useful if the cycle is interrupted for some reason. Pressing the buttons individually triggers a phone notification to buy detergent (right button) or dryer sheets (left) and displays a "Supplies Low" message on the app until the corresponding button is pressed again. These physical buttons are not replicated in the app because I felt they would only be used, if at all, while standing next to them.

As coded, the LEDs go out when the respective appliance is running and are lit when the cycle is complete. You might want to go the other way -- though the matter is hardly existential since if you can see the LEDs at all you can see whether the machines are running. That said, noting whether the LED changes state when the appliance is started does confirm everything is working OK.

Step 9: Code & Blynk Widgets

You can download the code from GitHub here. The latest version saves the running totals for cost and operating time to EEPROM (useful if you have a power cut, for example). I think the polite descriptor is hobby code. I've commented it fairly extensively so it probably doesn't need any more elaboration.

Almost certainly you will want to modify this to a greater or lesser extent - especially the washer cycle elements which are fairly tailored to my machine. And you'll need your own Blynk tokens.

The only other point I'd make is that nothing happens in the main loop except the "Blynk Magic" and the timer which controls the function calls. If you wanted to get serious about accuracy in monitoring power you'd almost certainly want the actual monitoring code to run in the main loop or at least call it more frequently. Calling it every five seconds seems fine for my purposes and yields power readings that at least make sense.

There's quite a lot of debugging output to the Serial Monitor, some of which is also useful for calibration. Some of it though is just distracting or is a legacy of earlier versions of the code. Sorry about that.

The project ended up using a nice cross-section of Blynk widgets. The graphical presentation is half driven by utility, half by aesthetics. One of the many insights I gained during this project was that one display widget can show lots of different information with very minimal coding. For example, one "Value" widget can show cycle run time, cycle run cost, total running time and total running cost. This minimizes display clutter and saves you a bit of Blynk "Energy," aka in-app purchases.

Step 10: The School Bus

Ah yes. Well. Although the primary alarm function is a phone notification it seemed prudent to provide an audible alert too. Right now, I've simply used a tone generator that's a bit louder than the one that beeps when the buttons are pressed. You can get them for a few cents apiece - although in my experience they vary widely in actual sound produced. A better approach would be to have the alarm sound generated by a proper smoke/heat detector. I will probably implement this at some point.

For the moment I've gone with something slightly more flamboyant, albeit more susceptible to failure.

As part of another project even more whimsical than this one, I modified a folk-artsy school bus (which I repainted in hometown livery but did not otherwise make) so that it had flashing lights, a servo-controlled "stop" sign and synchronized sound effects. All controlled with illuminated arcade game buttons cunningly disguised as headlights, tail lights etc. Or if you preferred with another Blynk app. In practice, the school bus became a giant case for the Raspberry Pi that controlled these operations.

Since the school bus already played loud sounds through external speakers, it was a relatively trivial task to record some additional files with "cool" alarm sounds and use the Blynk "bridge" widget to play those sounds and flash the school bus lights when the Laundry Monitor alarms are activated.

The results of this perverted science can be seen in the video at the beginning of this post.

Microcontroller Contest 2017

Participated in the
Microcontroller Contest 2017