Laundry's Done!

Laundry's Done!
Photo by PlanetCare / Unsplash

Well there's still folding and stuff left but getting notified when the washer/dryer cycle finished was one of my first projects and is a big hit with the wife.  An accelerometer detects when motion has ceased and sends a notification.  I'm using micropython with an ESP32, MQTT, Home Assistant, and Twilio to send text messages but you can adapt any or all of those to suit your needs.


Cute huh?

Supplies

  • GY-521 - Accelerometer/Gyroscope
  • ESP32 Mini - Perfect small package to mount the GY-521 on
  • Soldering iron
  • Double sided tape

When you purchase through links on this site, I may earn an affiliate commission.

Wiring

There are no actual wires per se...  Solder one of the female pin headers to the ESP32 Mini row that has VCC/GND.  Then break off a 4 pin strip of male headers and solder that to VCC<->SDA on the GY-521 (make sure the pins are oriented properly so the GY-521 will hang above the ESP32).  Then insert the GY-521 onto the ESP32 Mini making sure you've lined up VCC/GND and you'll end up with SCL on IO16 and SDA on IO17.  That's it!

Code

Getting Started With Micropython

1. Getting started with MicroPython on the ESP32 — MicroPython latest documentation

MPU6050-ESP8266-MicroPython

GitHub - adamjezek98/MPU6050-ESP8266-MicroPython: Simple library for MPU6050 on ESP8266 with micropython
Simple library for MPU6050 on ESP8266 with micropython - GitHub - adamjezek98/MPU6050-ESP8266-MicroPython: Simple library for MPU6050 on ESP8266 with micropython
https://github.com/adamjezek98/MPU6050-ESP8266-MicroPython

Grab mpu6050.py and upload that to your ESP32.

micropython-mqtt

GitHub - peterhinch/micropython-mqtt: A ‘resilient’ asynchronous MQTT driver. Plus a means of using an ESP8266 to bring MQTT to non-networked targets.
A &#39;resilient&#39; asynchronous MQTT driver. Plus a means of using an ESP8266 to bring MQTT to non-networked targets. - GitHub - peterhinch/micropython-mqtt: A &#39;resilient&#39; asynchronous M…

Grab mqtt_as/mqtt_as.py and upload that to your ESP32.  Grab mqtt_as/mqtt_local.py but we'll need to tweak that with your WiFi and MQTT broker settings.

config['server'] = '<broker hostname>'

config['ssid'] = '<SSID>'
config['wifi_pw'] = '<WiFi password>'
config['ssl'] = <True | False>
config['port'] = <broker port>
config['user'] = '<broker user>'
config['password'] = '<broker password>'
Sample mqtt_local.py updates.

This project's code

GitHub - scarey/laundry-is-done
Contribute to scarey/laundry-is-done development by creating an account on GitHub.

Grab main.py and upload it to the root of your ESP32.

Update 06/25/23: Publish configuration to esp32/washer/config with retain set. You need to tweak the "sensitivity" based on your washer/dryer and lower it if it thinks it's done too early.  Increase it if it never thinks it's done.  You can also increase the "maxIdlePeriods" if necessary (it's the number of samples in a row that need to be less than the "sensitivity" to be considered all done).

{
  "sensitivity": 100,
  "sampleSecs": 10,
  "maxIdlePeriods": 6
}
esp32/washer/config

Home Assistant

MQTT Integration

I have a Mosquitto MQTT broker running and integrated with HA.  For the interface I just added a text field to show the last acceleration values to make fine-tuning easier and a switch to enable the monitoring.

mqtt:
  sensor:
  - unique_id: dryervib
    name: "Dryer vibration"
    unit_of_measurement: "XYZ sum"
    value_template: >-
      {%- set parts = value[1:-1].split(",") -%}
      {{ int(parts[0]) + int(parts[1]) + int(parts[2]) }}
    state_topic: "esp32/washer/readings/1"

  switch:
  - unique_id: dryermon
    name: "Dryer monitor"
    state_topic: "esp32/washer/active/1"
    command_topic: "esp32/washer/active/1/set"
    availability:
    - topic: "esp32/washer/status"
    payload_on: "on"
    payload_off: "off"
    optimistic: false
Home Assistant configuration.yaml
Android Home Assistant app

Notification

I use Twilio to send texts when motion has ceased.  It has good integration with Home Assistant and you can use a simple HA Automation or I prefer Node-Red.


Notes

  • You may need to tune the sensitivity and/or the number of idle periods if you find it is notifying before the cycle is done or never notifies.
  • If desired, separate accelerometers could be used for independent sensing of washer and dryer.  I haven't tried it but for the GY-521 I linked to it says connecting VCC to AD0 will change the address of the second module so they can both be used at the same time.
  • MQTT is my preferred way to have the ESP32 communicate.  You could have the ESP32 handle everything by maybe adding a physical button to start monitoring and directly make a request to Twilio or your wireless carrier to send a notification.
  • 9/7/23 - I just updated to Home Assistant 2023.9.0 and it didn't like how I was separating the acceleration values so I updated the config above to combine XYZ into a single number.
Technology icons created by Freepik - Flaticon