Home Assistant Community

Laundry Sensors with NodeMCU and Home Assistant


This is a guest post by Home Assistant user and contributor Nolan Gilley.

Today I’ll show you how I used Home Assistant, a NodeMCU (ESP8266), and a couple of accelerometers to automate our laundry room. This is a rewrite of an old post where I did the same thing using a Moteino & Raspberry Pi. This version only requires a NodeMCU.

We have an older washer and dryer which doesn’t have any form of notification when cycles complete. Home Assistant was the obvious solution, I just needed to create sensors for the washer and dryer. I tried using sound sensors but found them unreliable. I ended up using an accelerometer attached to the back of each appliance. I also added magnetic reed switches on the doors of the washer and dryer to detect whether they’re open or closed. I connected the accelerometers and reed switches to an NodeMCU which will relay the data to my MQTT broker.

Block diagram of schematic

After taking some sample data from the accelerometers while each appliance was in operation, I decided to plot the data to help determine the proper thresholds of when the devices were running or off. I had to do this in order to get precise ranges so the dryer sensor wouldn’t get tripped by the washer or vice versa. In the plot below you can see the acceleration in each direction for the accelerometer connected to the dryer. It’s easy to see when the dryer is in operation here. I used the same technique for the washer’s accelerometer.

Graph showing the accelerometer data

Next it was just a matter of integrating everything with Home Assistant. I was able to use the MQTT component to read the washer and dryer states from the Moteino and display it in Home Assistant.

Status of the dryer and washer in Home Assistant

Next I wrote scripts that are run whenever the washer or dryer completes a load. This is triggered by the automation component. When the laundry is complete I have the lights in the house turn red and notify me via Join. Once the door is opened and laundry emptied another script runs that sets the lights back to normal. So far it has been very helpful and very reliable.

NodeMCU connected to MPU-6050 accelerometer.

Materials used:

Sketch for the NodeMCU is available here.

Home Assistant Configuration:

  port: 1883
  keepalive: 60
  qos: 0
  - platform: mqtt
    name: "Dryer Status"
    state_topic: "sensor/dryer"
    unit_of_measurement: ""
  - platform: mqtt
    name: "Washer Status"
    state_topic: "sensor/washer"
    unit_of_measurement: ""
  - alias: Washer complete
      platform: state
      entity_id: sensor.washer_status
      from: 'Running'
      to: 'Complete'
      service: script.turn_on
      entity_id: script.washer_complete
  - alias: Washer emptied
      platform: state
      entity_id: sensor.washer_status
      from: 'Complete'
      to: 'Empty'
      service: scene.turn_on
      entity_id: scene.normal
    alias: Washer Complete
      - alias: Join Notification
        service: notify.join
          message: "The washing machine has finished its cycle, please empty it!"
      - alias: Living Room Lights Blue
        service: scene.turn_on
          entity_id: scene.blue

Resources used:

This is a companion discussion topic for the original entry at https://home-assistant.io/blog/2016/08/03/laundry-automation-update/

Manual timer in frontend

You sir are a legend, I am going to use a modified version of this to create a washing machine sensor.

If I only need one MPU6050 (got a washer/dyer combo unit) then do I only need to connect the 5V GND SCL SDA pins. The AD0 pin is only needed for an additional MPU6050.



Great trick! Just a question from my end; why not going for a solution that measures the absorbed electricity? That’s what I am using quite reliable.

1 Like


I have this exact use case, a Sonoff Pow monitoring the power usage, with an automation that sends a push bullet when the wattage drops below 5 watts for 2 mins, then switches off the Sonoff Pow.

Works perfectly and reliably.



Can you post your code from home assistant for me too look at, I got loads of pre-flashed Sonoffs boxes just laying around.



figured out the code needed for a POW Sonoff.



This is great. When the washer hits the soak cycle, does that report that it’s complete? I never would have thought of using an accelerometer, I’m going to have to try this.



May I know where and how do you attach the accelerometer? Do you need to open up the washing machine? A picture will definitely help.

1 Like


What did you use to monitor the x, y and z ranges in order to set the threshold values?



A couple of questions about this implementation:

  1. Looking at the NodeMCU pin-out it appears as though it does not have 5V, SCL and SDA pins. So, how do you hook the MPU-6050 to the NodeMCU?
  2. What are the resistor values used for the reed switches? Do you have an actual wiring diagram of this implementation?





SCL is D1 and SDA is D2 on the NodeMCU. At least from what I could find. Came to ask about the library for programming. I couldn’t figure out which #include “I2Cdev.h” to use. I found a rowberg on github but I couldn’t figure out how to get it to compile. I got it all together and programmed but it’s not responding to anything other than MQTT.

The reed switches I built I used 330k, no idea if that works though. I couldn’t get a single MPU6050 to respond to the program. I’m guessing it’s the library I used.

OP hasn’t responded ever in this thread so I’m guessing we’re on our own. If you find another setup that works with ESP & 6050’s come back and post it plz. I’ll do the same.



Have you thought about doing it in EspHome? The I2C bus is simple to set up, but I haven’t used it with one of these MPU sensors, only with a pressure sensor. It doesn’t seem like it would be too difficult, the data for individual axis’ would be available straight to HA and you could automate from there.
I just bought a couple on Aliexpress, so I’ll know in about 3-4 weeks…