Washing Machine Alarm

We have a new-born baby in the house, which means we do a lot of laundry. Also we have a new-born baby in the house which means we don't have enough sleep. Together these facts mean that we do a lot of laundry, and frequently forget to check on the machine.

This project is a simple one which will facilitate sending an alarm when the washing machine finishes.

Hardware

The hardware for this project is simple:

  • 1 x WeMos Mini D1 - Approximately €2.50.
  • 1 x Vibration sensor - Approximately €0.80.

Wiring the project is very simple, and merely consists of connecting the vibration alarm to the Mini D1 board, which is powered by a simple USB-PSU:

  1. Vcc -> Vcc
  2. Group -> Ground
  3. DO ("Digital Out") -> WeMos D1 D1

 

Vibration Sensor:

The result..

Software

The software for this project is pretty simple it just involved a lot of patience to test. In short we sample the vibration sensor every 30 seconds, for five minutes. We read a "1" when there is a vibration, and a "0" when there is none.

We define a set of states:

  • QUIET
    • No vibrations were heard in the previous five minutes. This is the starting state.
  • NOISY
    • Vibrations were heard in the previous five minutes.
    • In my case I regard things as "noisy" if 3, or more, of the 10 samples were showing vibration.
  • FINISHED
    • This is the magic state which means we're done.

So the code samples for five minutes, then decides what state it is in based on the previous state. If there were no vibrations over the previous five minutes - but the five minutes before that there were then we're finished, for example.

Hopefully my logic is readable and correct.

The software will also connect to the local WiFi network on startup, and will serve a HTTP-page showing the previous ten samples, and the current state.

Every time a state-transition occurs the device will make a HTTP-call to another server which will be responsible for actually alerting when we see "FINISHED" for the first time.

The Code

The complete code looks like this:

Download the code.

Onboard HTTP Server

As mentioned the code will also launch a HTTP-server, which will output the current state, as well as the vibration-records which have been stored. The result is a very simple page looking like this:

On-board HTTP-server

The asterisk denotes the current reading - so the readings above that are current, and below are from the previous 5minute interval.

Future Challenges?

It might be nice to make the alerting more local - for example a buzzer could make an annoying noise, or we could play an MP3.

Recent Changes

The state transition handled the obvious case, right from the start:

  • Quiet (not running) -> Noisy (running) -> Quiet (finished)

But there was no transition back, so I've added a record of the cycle finishing - that way 30 minutes after we hit the "finished" state we revert back to the "quiet" phase. This means you no longer need to reset the device to track another cycle.