Detecting finished laundry cycle

I'm exploring a few options to detect when the washing machine at home has finished its cycle.
Jan 14, 2024 — 4 mins read — Home Assistant

Detecting finished laundry cycle

For this week's project, I wanted to explore and learn how I can detect when the washing machine at home has finished its cycle so a notification can be sent via Home Assistant.

The washing machine we have at home has zero smart features and it is not connected to the Internet in any way. Because of that, I was thinking of implementing some sort of sensor that will attach to the machine and add this capability but in a non-invasive way where no physical modification is needed on the machine.

To do this, I tried out two options: one involving a vibration sensor, and another one with an LDR (Light dependent resistor).

For the vibration sensor, I used a piezo disk that I connected to the ESP32 in between a voltage divider of two 1 MOhm resistors between 3.3V and GND. The GND wire of the sensor is connected to the GND, while the positive connection is connected to the midpoint of that voltage divider.

The midpoint is then connected to pin 34 on the ESP32 and it is set as an analog input. The value from this pin is read and the output is then plotted to the Arduino plotter so we can visualize the vibrations picked up from the sensor.

While the detection worked, it was really noisy at times and I did not really feel comfortable using this in the final detector as I was worried about false positives so I proceeded to explore the LDR option next. The Arduino code that runs on the ESP32 is available below.

const byte piezoPin = 34;
int rawValue;

void setup() {
  Serial.begin(115200);
}

void loop() {
  rawValue = analogRead(piezoPin);
  if(rawValue < 1920 || rawValue > 1960) { // some deadband
  Serial.println(rawValue);
  }
  delay(2);
}

The LDR is connected in series with a 10 kOhm resistor to form a voltage divider between 3.3v and GND on the ESP32 and its midpoint is connected to pin 32 on the ESP32. The ESP32 is running ESPHome in this case and an ADC sensor is set so we can read the raw value of it.

To test it out on the bench, I used an LED to shine at the LDR while keeping it hidden from external light with a heat shrink tubing and I was easily able to detect the LED turning on.

This can now be mounted to the washing machine's finished LED indicator and once lit, I can set an automation to send me a notification.

The ESPHome definition for the sensor is available below.

sensor:
  - platform: adc
    pin: 32
    raw: true
    attenuation: 11dB
    name: "LDR Sensor"
    update_interval: '5s'
    unit_of_measurement: " "
    accuracy_decimals: 0

As a final option, I also considered adding a current sensor to the machine and monitoring its power usage but this can also be done with a suitable smart plug with power monitoring that is rated for the power consumption of the machine. Once the machine starts drawing power we can initialize a flag that the cycle is started and after a certain period of time with no power being consumed, we can conclude that the cycle has ended.


In my case, I will go with the LDR variant and attach the LDR on the LED with some double-sided tape so it is noninvasive on the machine. However, I had a lot of fun exploring the other options and I hope that you managed to learn something from it.

Tools and materials used in the video:


diy esphome sensor
Read next

Movement detection in Adruino and ESPHome

Detecting motion is the basis of a lot of automation, so in this article and video, I'm going through the basics of using a Mini PIR sensor...

You might also enojy this

Fixing the Instagram feed in my website footer

While writing the blog post for the workshop air filter that I made, I noticed that the usual Instagram feed that I’ve placed on the bottom...