The older the smarter: let's pimp a laundry machine

The old laundry machine here was facing a problem recently that the door was only recognized as closed when almost kicking it to shut it. So I needed 6 or 7 tries at least until the lock snapped in somehow and the laundry process started.
 ZV-466 door lock
So, obviously the lock needed to be repaired. The lock itself is actually very well engineered technology. There is an insightful video only about this lock here which is worthwhile watching. (...and chances that your laundry is having a ZV-446 lock, too, are not that small.)

That brought me to the idea that it would be nice to get a message on the phone when the laundry machine has finished. Understanding that there is an electric signal telling when the door lock of the laundry machine is opened or closed that should be an easy one to implement. 

Thinking it to and end: if the laundry machine is open for maintenance anyway, why not also putting two little pumps inside and having one of these fancy automatic laundry detergent dosing systems, which probably doubles the functional value of this 15 yrs old laundry machine?

So I've started with getting a few parts:

- 2 x perestaltic pumps
- 3m rubber hose
- a 12V power adapter (2A just to be on the safe side)
- 1x sonoff basic module (again)
- an I2C-port extension (MCP23017)
- a board with 2 relays catering for my lazyness to put that together myself
- 1x optocoupler
- 2x 100k and 1uF capacitor
- 3 switches I forgot on this photo as well as some cabling

The idea was that the "detergent system" will automatically pump the right amount of the right detergent into the laundry machine, as soon as the laundry process starts.

There should be 3 switches: first one enabling or block the dosage system, second one for full or half amount of detergent, third one for choosing the detergent with or without bleaching (=pump 1 or pump 2)

Thinking it through it turned out that just the one relay on the sonoff board is enough to do the job. So the two additional relays and the I2C port extender is not needed:


In short: the more recent models of sonoff switches have in total 5 pins, which can be of use of additional external function: 3.3v, GPIO3 (RX), GPIO1(TX), Ground, GPIO14. 
That translates into 3 I/O ports for extras, but with a small caveat: TX cannot be used for anything which might be pulled to ground while the sonoff module is booting, because that will cause it to boot into a test mode (which I've noticed when the first version of it was already mounted inside of the laundry machine of course :-( ... more on that issue here )

The sonoff module is flashed with Tasmota (9.5.1). In the configuration I set the 3 ports RX, GPIO 14 and TX to switch1, switch2 and switch3.
On the console of the tasmota firmware the right behavior of the tasmota module is set like this:

savedata 1
poweronstate 0
setoptions114 1

rule1 ON switch1#Boot==1 DO var1 1 ENDON ON switch1#Boot==0 DO var1 0 ENDON ON switch2#Boot==1 DO var2 900 ENDON ON switch2#Boot==0 DO var2 500 ENDON ON switch1#State==1 DO var1 1 ENDON ON switch1#State==0 DO var1 0 ENDON ON  switch2#State==1 DO var2 900 ENDON ON switch2#State==0 DO var2 500 ENDON ON switch3#State==1 DO Backlog Power %var1%;Delay %var2%;Power 0 ENDON

rule1 1
savedata 0

In this configuration switch 1 is disabling/enabling automatic laundry detergent dispensing. Switch 2 changes between full and small amount of detergent (90 seconds vs 50 seconds of pumping). And switch 3 is indicating the active door lock of the laundry machine and kicks-off the pumps. 

Some of the parts in the rules look like repetition, but they are not: it is necessary to get to know the position of the switches also right after boot already and not only if they change. The slightly weird solution with variable 1 (var1) for enabling/disabling the whole logic is due to the fact that this tasmota version was compiled without "if/then" support and I was too lazy to flash that thing another time. 

Switch 4 is not part of the logic, but simply switches hardwired between the two pumps. That saved me the port extension and at least one additional relay. Downside is: the module doesn't know which of the two detergents is getting used. So no chance to give a warning if one of the bottles needs a refill.


This is the complete mess before mounting it into the laundry machine. The switches are not connected to the sonoff module there, but all soldered to a 5 pin plug which fits on the "extension port" of the sonoff. The optocoupler with its resistors and capacitor is completely isolated with black shrink tubing in the middle of the picture. 
As I do not have my 3D printer here, I made a very simple mount for the two pumps out of wire. Sturdy enough to keep the pumps in place later. 

😱  

Meanwhile I've upgraded the whole thing with a proper 3D printed mount for the pumps: 

In case someone wonders why there is a cut in the mount holes for the pumps: this is to avoid that I have to solder the cables to the pumps again, as the pump heads are bigger than the actual engine and the cables are connected from below.
The stl-file I've uploaded on thingiverse here.

I have mounted the pumps in a free corner between the water valve and the detergent enclosure for manual detergent filling. 
The hoses are ending in the enclosure of this detergent drawer. I have used these barb fittings for it. Next time I would probably take them one size bigger as the hose doesn't fit very tight. As laundry machines are prone to vibration, I've secured the ends of the hose with additional cable ties around it.



The inlets are more or less exactly where the water from the detergent drawer hits the inside of the box and washes the in-flowing detergent away into the drum.



The hoses are getting out on the backside of the machine, into the two bottle of detergent. 
Maybe I will build a stand or something later for it so they are not falling in case the machine moves a bit while spinning... ;-)

The rest of the electronics I've glued somewhere inside of the laundry machine where it looked spacious and secure enough to do so: it probably makes sense to always consider the following things:
- Can anything get loose or fall due to vibration of the machine?
- Are any additional parts close to anything inside the machine that will probably get very hot? (depending on laundry program)
- If there is a failure of the laundry machine, how likely will the add-ons being drowned in water?

So, the front panel got some new "Automatic Dosing" features:
First switch turning automatic dosing on/off.
Second for full or half load and third switch for choosing between non-bleaching and bleaching detergent.
Not very well designed, but appropriate for a 15 yrs old machine. :)

And at the very end I get a message like this on my phone. Unfortunately this is the point where all the home automation abruptly ends somehow... 

Questions? Ideas? Please leave a comment.

Comments