I took part in Jugend forscht last year, which is a national science competition on local, country and national level. For this contest I created a sensor for a washingmashine that can automatically find the right dosis of washing powder. Detergents like washing powder are usually polar and change the electrical resistence of the water. If too much washing powder is used, you get foam, which is air sourrounded by a very tiny film of water and detergents. Theoretically there are much less molecules that can transfer electric current (only the hull of the foambubbles) than in the water. So there must be a way to differenciate between foam and water by measuring the electric resistence. My sensor has 8 electrodes in different hights for scanning the waterlevel and the foamlevel, using an NXT brick from Lego with a multiplexer and a port extender via I2C.
If all detergents have solved the dirt, there is no foam (theoretically). So all you need to do is add detergents vergy gently until foam starts to build up.
So you won’t support the pollution of the environment by guessing the ammount of washing powder needed.
I got second prize in country-level and an extra award for research in environmently friendly technology.