We have an LG Direct Drive, front loading washing machine in our home. Whilst I don't want a 'smart' washing machine, I would like our smart home to know when it has finished its cycle, so that it can send the family members at home a notification (because only they can take action) and also make a whole home voice announcement.
This is not a photo of my kitchen but, the machine is the same.
If your washing machine is inside a utility room with a door to keep the noise at bay, then you are not going hear when the machine has finished its cycle. This approach lets everyone in the house know via a notification and a whole home voice announcement, so that the washing can be hung out on the line.
Sometimes it's also handy when you are busy outside in the shed or garden. My wife often puts the washing machine on before she goes to work and assumes that another family member will hang the washing out on the line when the cycle is complete. This way, everyone in the house gets a reminder.
The general concept can be used to extend the reach of audible notifications from 'dumb' appliances. This is the only 'smart' feature that I want from my washing machine (other than good water and energy efficiency).
It is possible to measure power usage of the machine using a smart plug but smart plugs simply doesn't have the resolution or responsiveness to do this task well. You also can't control the sample period and reporting period. The power usage also varies throughout the cycle and there are periods where it looks like it has finished but it hasn't.
Another approach is to use an ACS712 hall effect sensor and I have developed a smart home ac current sensing module and used it successfully on various appliances. This gives me much greater resolution, sensitivity and full control over the sample periods but, even this would struggle due to the long periods of inactivity in the washing cycle. There would be a long delay between the actual cycle end and the point of being confident enough to generate an end of cycle event.
The washing machine has a complex cycle and it also varies a lot, depending on the selected wash programme. Some people have used vibration sensors but, these won't give an accurate end of cycle time because the machine sits still and silent for long periods and does this several times during its cycle. This approach would also result in a long delay between the actual end of cycle and being confident enough to generate an end of cycle event.
The only accurate and timely indicator of when the machine has finished its cycle is when it plays this tune: WashingMachine.m4a
So, this project is to see if I can accurately sense when this tune has been played by developing a 'tune detector', which I can then integrate into my contextual smart home. As it happens, someone has already developed the hardware and software required in the form of this audio frequency detector project. I am using this as my starting point.
I plan to use an Arduino Mega 2560 Pro as this is my current preferred processor for use in my contextual smart home and is one of our smart home building blocks. This is an 'embedded' version of the Mega 2560 and is much more compact, at just 55mm × 38mm.
I've developed my own PCB to make this processor much easier to use.
For the audio detection, I'm using this Arduino 'High Sensitivity Sound Detection Module'. The module has a microphone and an auto-gain pre-amplifier for good sensitivity. It features both a digital and analogue output and I'm using the latter, connected to an analogue input on the Arduino.
There are two red LEDs on this module. The first indicates power and the second indicates the state of the digital output. You can set the trigger threshold using the on-board potentiometer. There is no sensitivity control for the analogue output.
The analogue signal is sampled and quantized (digitised). A Fast Fourier Transform (FFT) algorithm is then used on the data. This FFT converts the digital data from the approximate discrete-time domain result. The maximum frequency of the approximate discrete-time domain result is then determined and used by my code to detect the notes being played.
To make the testing much easier, I have the audio file on my iPhone.
The initial testing worked well, with the Arduino detecting frequencies and printing them out to screen. They is some noise in amongst this but, I then started to create a state machine to detect sequences of notes.
The sample code sampling frequency was set to 2048 and it must be twice the highest frequency to be detected. This causes a problem because the notes of the tune are above 1KHz and are therefore not detected. The code is picking up lower harmonics well though.
I used an app on my iPhone to work out the frequencies being played. The app does a real time FFT display and I used Audacity to play each note in a loop. This showed that the notes ranged from 2210 Hz to 2960 Hz. This means that my Arduino code is definitely only picking up the lower harmonics and not the primary frequencies.
So the next question is, just how fast a rate can you sample the analogue port at? There is an interesting article on this which suggests that the highest rate possible is 8928 Hz. This is probably a good rate to use for this application.
I modified my code to basically sample the analogue port as fast as possible and to time it, so I can dynamically measure the sample rate. It turns out that it is typically 8333 Hz using the Arduino Mega 2560 but, I'm measuring it dynamically in my code to ensure the code ports to any Arduino device. This approach works well and I can now detect the primary frequencies.
The next part of the puzzle involves matching detected frequencies to the actual notes. I could get my code to reliable detect the first 13 notes of the tune using a simple state machine but, I want to deploy a much better algorithm based on fuzzy logic.
I used Audacity to map out the tune in terms of frequencies over time. This required me to convert my .m4a file to a .wav file.
The tune is 9.0 seconds long, so I've mapped the tune into 45 points (each 200mS long) to provide a frequency map, against which I can compare the last 9 seconds of audio detected. Comparing the iPhone app frequencies to the sensor output showed a consistent difference, with the sensor over-reading the frequency by about 2%.
My code is sampling for frequencies between 1700 Hz and 3100 Hz and storing them in a rolling array with the frequency and associated timestamp. It then scores these values and compares the frequencies over time with that expected from the array of stored values for the tune. It is basically correlating the last 9 seconds in time with the expected tune frequencies. This gives a score and as expected there is a significant peak in the score at the end of the tune. This is then used to trigger and event being sent to my contextual smart home.
For best reliability, the sensor needs to be installed fairly close to the washing machine. The plan is to install it invisibly, on the wall behind the washing machine in a small ABS enclosure. The Arduino used will also be performing other functions:
One of these will be my Smartisant Flood & Leak Sensor FLD1 underneath the washing machine to detect leaks. This sensor is designed specifically for this type of installation and is a wired sensor with no batteries, to make it very reliable and future-proof.
I'm also plan to install a vibration sensor on the washing machine, purely as a research exercise.
Over my many years doing smart home (I started in 2004), I have developed my own library of code for Arduino processors and this includes functions to integrate it into my distributed Home Control System and connect numerous types of sensors. These 'slave processors' can then do clever stuff like local control, self-monitoring of performance, local signal conditioning and rate limiting, send warnings and errors, or host some functions locally.
This maximises reuse across my many smart home projects, making it very quick and easy to develop and test new smart home capabilities. My smart home also employs the concepts of technology abstraction, meaning my smart home is also technology agnostic. This allows old technologies or broken sensors and devices to be swapped out with new ones, with minimal effort and zero reconfiguration.
Most of the Arduino processors installed in my smart home use an Ethernet IP network interface, to enable them to send and receive events with my Home Control System, using my unified communications protocol. Wired networks ensure very low latency and hence a great user experience, though occasionally I will use Wi-Fi.
Adding sensors and devices to my Home Control System is simply a matter of adding one line of JSON for each one, to the main configuration file. This defines the name, zone, object type and also the details of the slave processor it is hosted or controlled by. All the intelligence is within my Home Control System, which receives and sends encrypted events using my unified communications protocol. It sends events to update my smart home on things like the temperature, humidity, fan state, appliance and lighting state changes, occupancy, etc.
Occasionally, our @smartest_home will tweet when the washing machine has finished its washing cycle.
As part of the personalised user experience, our contextual smart home sends a notification when the washing machine has completed its washing cycle.
In summary, this projects works and it works REALLY well! I can reliably detect the washing machine tune being played with an Arduino and sensor in the same room. The delay between the tune ending and the event being sent is less than 0.2 seconds.
My focus for this project is currently on a permanent installation.
I've used this project to detect a tune being played by my washing machine but, the same approach could be used with any device or appliance that plays a tune. It could also be used with door bells and chimes. I'm also currently testing to see if it can detect other alarms, including those from Amazon Echo devices.
One of the applications, I'm currently looking at is to detect when my Ender 3 Pro 3D printer has finished it's print job as it makes a beeping noise on completion.