Skip to content
  • MySensors
  • OpenHardware.io
  • Categories
  • Recent
  • Tags
  • Popular
Skins
  • Light
  • Brite
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Brand Logo
  1. Home
  2. My Project
  3. Washing machine state sensor

Washing machine state sensor

Scheduled Pinned Locked Moved My Project
32 Posts 10 Posters 21.3k Views 7 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • Moshe LivneM Moshe Livne

    @mvdarend you are a ray of sunshine, aren't you? I think power profiling is the way to go. although the washing machine will sit around doing nothing for a while (especially during pre-wash) I think it is still safe to say that there will be spikes of usage when heating, spinning, etc
    I am not too fussy about catching the machine the minute it finished so even 30 min with nothing over the threshold will be fine for me. I tend to leave the washing for DAYS in the machine :disappointed:
    I now have 3 different vibration sensors. They do work for an extent but as you said - the number of false positives is a pain.
    @Prateek-Gupta I think that is a bit of over solving a washing machine problem :-)

    Prateek GuptaP Offline
    Prateek GuptaP Offline
    Prateek Gupta
    wrote on last edited by
    #20

    @Moshe-Livne Yes, I agree. But then this could be applied to a numerous electrical appliances across your home. Almost, all the devices have a unique power signature down to different operating modes.

    1 Reply Last reply
    0
    • M Offline
      M Offline
      mvdarend
      wrote on last edited by
      #21

      Created a custom widget in HomeGenie and set it up to send PushBullet notifications. After running for a week I've noticed a few small problems.

      • If I leave the door open and the sun shines on the sensor, it's status changes to 'Running'. Increasing the threshold doesn't help so I'll need to protect the sensor from outside elements better. *
      • The LED on the machine also flashes just before it goes into running mode. I think I'll go with an extra status depending on the previous one (Off -> Flashing = 'stand by', Running -> flashing = 'Idle') or something like that.

      Washing machine.png

      • My 3D printer is ordered and on its way, so I'll be able to create a custom holder. You guys are killing my finances :)
      Moshe LivneM 1 Reply Last reply
      0
      • M mvdarend

        Created a custom widget in HomeGenie and set it up to send PushBullet notifications. After running for a week I've noticed a few small problems.

        • If I leave the door open and the sun shines on the sensor, it's status changes to 'Running'. Increasing the threshold doesn't help so I'll need to protect the sensor from outside elements better. *
        • The LED on the machine also flashes just before it goes into running mode. I think I'll go with an extra status depending on the previous one (Off -> Flashing = 'stand by', Running -> flashing = 'Idle') or something like that.

        Washing machine.png

        • My 3D printer is ordered and on its way, so I'll be able to create a custom holder. You guys are killing my finances :)
        Moshe LivneM Offline
        Moshe LivneM Offline
        Moshe Livne
        Hero Member
        wrote on last edited by
        #22

        @mvdarend While waiting for the current sensor (and also discovering that new powerboards have one way screws! evil people!), I have re-checked my vibration sensors. i am using this one http://www.aliexpress.com/item/1pc-lot-SW-420-Normally-Closed-Alarm-Vibration-Sensor-Module-Vibration-Switch-30512/32259757483.html which is better than the others i think.
        currently I am just monitoring 5 minute periods and if there is a vibration during this time I mark it as "active". my theory (that I can't check as I ran out of laundry) is that 3 periods of vibrations signal that a cycle is in progress. a period of quite means the cycle has finished. will post final results the minute the kids will produce enough dirty cloths.

        M 1 Reply Last reply
        0
        • Moshe LivneM Moshe Livne

          @mvdarend While waiting for the current sensor (and also discovering that new powerboards have one way screws! evil people!), I have re-checked my vibration sensors. i am using this one http://www.aliexpress.com/item/1pc-lot-SW-420-Normally-Closed-Alarm-Vibration-Sensor-Module-Vibration-Switch-30512/32259757483.html which is better than the others i think.
          currently I am just monitoring 5 minute periods and if there is a vibration during this time I mark it as "active". my theory (that I can't check as I ran out of laundry) is that 3 periods of vibrations signal that a cycle is in progress. a period of quite means the cycle has finished. will post final results the minute the kids will produce enough dirty cloths.

          M Offline
          M Offline
          mvdarend
          wrote on last edited by mvdarend
          #23

          @Moshe-Livne How is it working so far, have you been able to test it?

          Moshe LivneM 1 Reply Last reply
          0
          • M mvdarend

            @Moshe-Livne How is it working so far, have you been able to test it?

            Moshe LivneM Offline
            Moshe LivneM Offline
            Moshe Livne
            Hero Member
            wrote on last edited by
            #24

            @mvdarend so far so good. have added a bit of logic to my sketch and need another load to test it :-)

            this is the current sketch:

            // Washing machine finished sketch 
            
            #include <MySensor.h>
            #include <SPI.h>
            
            
            #define CHILD_ID 3
            #define BUTTON_PIN  3  // Arduino Digital I/O pin for button/reed switch
            #define SAMPLING_PERIOD 600000
            MySensor gw;
            int oldValue=-1;
            unsigned long period_start = millis();
            int state = -1;
            
            
            // Change to V_LIGHT if you use S_LIGHT in presentation below
            MyMessage msg(CHILD_ID,V_TRIPPED);
            
            void setup()  
            {  
              gw.begin();
            
             // Setup the button
              pinMode(BUTTON_PIN,INPUT);
              // Activate internal pull-up
              digitalWrite(BUTTON_PIN,HIGH);
              
              // After setting up the button, setup debouncer
            
              // Register binary input sensor to gw (they will be created as child devices)
              // You can use S_DOOR, S_MOTION or S_LIGHT here depending on your usage. 
              // If S_LIGHT is used, remember to update variable type you send in. See "msg" above.
              gw.present(CHILD_ID, S_DOOR);  
            }
            
            void report_state(int state)
            {
            	  	Serial.print("reporting state: ");
            		Serial.println(state); 
            	    gw.send(msg.set(state));
            	
            }
            
            int prev_state = -1;
            int prev_state_length = 0;
            
            //  Check if digital input has changed and send in new value
            void loop() 
            {
              // Get the update value
              int value = digitalRead(BUTTON_PIN);
              
              if (value == 1) {// 0 means vibration detected
              	state = 1; 
              	Serial.println("setting state to 1");
              }
              Serial.println(millis()-period_start);
              
              if (millis() - period_start > SAMPLING_PERIOD) {
              	period_start = millis();
              	Serial.println(state);
                if (state != prev_state) {
              		if (state == 1 && prev_state_length > 2) { //a vibration period after long period of quit means a cycle started
              	    	report_state(state);
            	    	prev_state_length = 1;
              		
              		} else if (state == 0 && prev_state_length > 2){ //a long quite period after a cycle means cycle finished
              			report_state(state);
              			prev_state_length = 1;
              		}
              	}
            	prev_state = state;
                state = 0;
              	
              }
              
             
              delay(100);
            } 
            
            

            will refine it once i verify it works through all the different cycles - this is not even a tested version, just to give you an idea about how it works. looks promising so far.

            1 Reply Last reply
            0
            • Moshe LivneM Offline
              Moshe LivneM Offline
              Moshe Livne
              Hero Member
              wrote on last edited by
              #25

              found some flaws in the logic - updated and checking - do not use the code above

              BulldogLowellB 1 Reply Last reply
              0
              • Moshe LivneM Moshe Livne

                found some flaws in the logic - updated and checking - do not use the code above

                BulldogLowellB Offline
                BulldogLowellB Offline
                BulldogLowell
                Contest Winner
                wrote on last edited by BulldogLowell
                #26

                @Moshe-Livne

                I think you can make this easier...

                It looks like you are looking for two motion events in the past two minutes to indicate washer is on?

                something like this (untested)

                // Washing machine finished sketch
                
                #include <MySensor.h>
                #include <SPI.h>
                
                #define CHILD_ID 3
                #define BUTTON_PIN  3  // Arduino Digital I/O pin for button/reed switch
                #define SAMPLING_PERIOD 600000UL
                MySensor gw;
                unsigned long motionTime;
                unsigned long lastMotionTime = millis();
                boolean lastSensorState = false;
                boolean lastWasherState = false;
                MyMessage msg(CHILD_ID, V_TRIPPED);
                
                void setup()
                {
                  gw.begin();
                  pinMode(BUTTON_PIN, INPUT_PULLUP);
                  gw.present(CHILD_ID, S_DOOR);
                }
                
                void loop()
                {
                  boolean sensorState = digitalRead(BUTTON_PIN);// Get the updated sensor value
                  if (sensorState != lastSensorState && lastSensorState == true) //detect state change from true to false
                  {
                    lastMotionTime = motionTime; //cascade time back 
                    motionTime = millis();
                  }
                  lastSensorState = sensorState;
                  //
                  boolean washerState = (motionTime - lastMotionTime < SAMPLING_PERIOD && motionTime - millis() < SAMPLING_PERIOD); 
                  if (washerState != lastWasherState)
                  {
                    gw.send(msg.set(washerState));
                  }
                  lastWasherState = washerState;
                }
                
                Moshe LivneM 2 Replies Last reply
                0
                • BulldogLowellB BulldogLowell

                  @Moshe-Livne

                  I think you can make this easier...

                  It looks like you are looking for two motion events in the past two minutes to indicate washer is on?

                  something like this (untested)

                  // Washing machine finished sketch
                  
                  #include <MySensor.h>
                  #include <SPI.h>
                  
                  #define CHILD_ID 3
                  #define BUTTON_PIN  3  // Arduino Digital I/O pin for button/reed switch
                  #define SAMPLING_PERIOD 600000UL
                  MySensor gw;
                  unsigned long motionTime;
                  unsigned long lastMotionTime = millis();
                  boolean lastSensorState = false;
                  boolean lastWasherState = false;
                  MyMessage msg(CHILD_ID, V_TRIPPED);
                  
                  void setup()
                  {
                    gw.begin();
                    pinMode(BUTTON_PIN, INPUT_PULLUP);
                    gw.present(CHILD_ID, S_DOOR);
                  }
                  
                  void loop()
                  {
                    boolean sensorState = digitalRead(BUTTON_PIN);// Get the updated sensor value
                    if (sensorState != lastSensorState && lastSensorState == true) //detect state change from true to false
                    {
                      lastMotionTime = motionTime; //cascade time back 
                      motionTime = millis();
                    }
                    lastSensorState = sensorState;
                    //
                    boolean washerState = (motionTime - lastMotionTime < SAMPLING_PERIOD && motionTime - millis() < SAMPLING_PERIOD); 
                    if (washerState != lastWasherState)
                    {
                      gw.send(msg.set(washerState));
                    }
                    lastWasherState = washerState;
                  }
                  
                  Moshe LivneM Offline
                  Moshe LivneM Offline
                  Moshe Livne
                  Hero Member
                  wrote on last edited by
                  #27

                  @BulldogLowell It is slightly more complicated (but not much). the machine can idle for 5-10 min (well, not really idle, but idle enough so no vibrations will be felt). so, the current logic marks 5 minute periods. a vibration period marks the beginning of the cycle and 2 or 3 (yet to be determined) periods of quite marks end of cycle.

                  BulldogLowellB 1 Reply Last reply
                  0
                  • Moshe LivneM Moshe Livne

                    @BulldogLowell It is slightly more complicated (but not much). the machine can idle for 5-10 min (well, not really idle, but idle enough so no vibrations will be felt). so, the current logic marks 5 minute periods. a vibration period marks the beginning of the cycle and 2 or 3 (yet to be determined) periods of quite marks end of cycle.

                    BulldogLowellB Offline
                    BulldogLowellB Offline
                    BulldogLowell
                    Contest Winner
                    wrote on last edited by BulldogLowell
                    #28

                    @Moshe-Livne

                    so if no vibration is sensed in the past five (configurable) minutes machine is OFF, otherwise machine is ON?

                    likewise you want to indicate Washing when two vibrations are sensed in less than two or three (configurable) minutes?

                    yes?

                    1 Reply Last reply
                    0
                    • BulldogLowellB BulldogLowell

                      @Moshe-Livne

                      I think you can make this easier...

                      It looks like you are looking for two motion events in the past two minutes to indicate washer is on?

                      something like this (untested)

                      // Washing machine finished sketch
                      
                      #include <MySensor.h>
                      #include <SPI.h>
                      
                      #define CHILD_ID 3
                      #define BUTTON_PIN  3  // Arduino Digital I/O pin for button/reed switch
                      #define SAMPLING_PERIOD 600000UL
                      MySensor gw;
                      unsigned long motionTime;
                      unsigned long lastMotionTime = millis();
                      boolean lastSensorState = false;
                      boolean lastWasherState = false;
                      MyMessage msg(CHILD_ID, V_TRIPPED);
                      
                      void setup()
                      {
                        gw.begin();
                        pinMode(BUTTON_PIN, INPUT_PULLUP);
                        gw.present(CHILD_ID, S_DOOR);
                      }
                      
                      void loop()
                      {
                        boolean sensorState = digitalRead(BUTTON_PIN);// Get the updated sensor value
                        if (sensorState != lastSensorState && lastSensorState == true) //detect state change from true to false
                        {
                          lastMotionTime = motionTime; //cascade time back 
                          motionTime = millis();
                        }
                        lastSensorState = sensorState;
                        //
                        boolean washerState = (motionTime - lastMotionTime < SAMPLING_PERIOD && motionTime - millis() < SAMPLING_PERIOD); 
                        if (washerState != lastWasherState)
                        {
                          gw.send(msg.set(washerState));
                        }
                        lastWasherState = washerState;
                      }
                      
                      Moshe LivneM Offline
                      Moshe LivneM Offline
                      Moshe Livne
                      Hero Member
                      wrote on last edited by
                      #29

                      @BulldogLowell re-reading your code, it would work well. the reason I made the "periods" was more to help me debug the scenario as I didn't want to sift through zillions of on/off.

                      1 Reply Last reply
                      0
                      • BulldogLowellB Offline
                        BulldogLowellB Offline
                        BulldogLowell
                        Contest Winner
                        wrote on last edited by BulldogLowell
                        #30

                        yeah, that is why it is important to just print() when there are state changes... added configuration and debug:

                        // Washing machine finished sketch
                        
                        #include <MySensor.h>
                        #include <SPI.h>
                        
                        #define CHILD_ID 3
                        #define BUTTON_PIN  3  // Arduino Digital I/O pin for button/reed switch
                        #define ONE_MINUTE 600000UL
                        MySensor gw;
                        unsigned long motionTime;
                        unsigned long lastMotionTime = millis();
                        boolean lastSensorState = false;
                        boolean lastWasherState = false;
                        MyMessage msg(CHILD_ID, V_TRIPPED);
                        
                        void setup()
                        {
                          gw.begin();
                          pinMode(BUTTON_PIN, INPUT_PULLUP);
                          gw.present(CHILD_ID, S_DOOR);
                        }
                        
                        void loop()
                        {
                          boolean sensorState = digitalRead(BUTTON_PIN);// Get the updated sensor value
                          if (sensorState != lastSensorState && lastSensorState == true) //detect state change from true to false
                          {
                            lastMotionTime = motionTime; //cascade time back 
                            motionTime = millis();
                          }
                          lastSensorState = sensorState;
                          //
                          boolean washerState = ((motionTime - lastMotionTime < ONE_MINUTE * 2) && (motionTime - millis() < ONE_MINUTE * 5)); 
                          if (washerState != lastWasherState)
                          {
                            gw.send(msg.set(washerState));
                            Serial.print(F("Washer is "));
                            Serial.println(washerState? F("ON") : F("OFF"));
                          }
                          lastWasherState = sensorState;
                        }
                        
                        Moshe LivneM 1 Reply Last reply
                        0
                        • BulldogLowellB BulldogLowell

                          yeah, that is why it is important to just print() when there are state changes... added configuration and debug:

                          // Washing machine finished sketch
                          
                          #include <MySensor.h>
                          #include <SPI.h>
                          
                          #define CHILD_ID 3
                          #define BUTTON_PIN  3  // Arduino Digital I/O pin for button/reed switch
                          #define ONE_MINUTE 600000UL
                          MySensor gw;
                          unsigned long motionTime;
                          unsigned long lastMotionTime = millis();
                          boolean lastSensorState = false;
                          boolean lastWasherState = false;
                          MyMessage msg(CHILD_ID, V_TRIPPED);
                          
                          void setup()
                          {
                            gw.begin();
                            pinMode(BUTTON_PIN, INPUT_PULLUP);
                            gw.present(CHILD_ID, S_DOOR);
                          }
                          
                          void loop()
                          {
                            boolean sensorState = digitalRead(BUTTON_PIN);// Get the updated sensor value
                            if (sensorState != lastSensorState && lastSensorState == true) //detect state change from true to false
                            {
                              lastMotionTime = motionTime; //cascade time back 
                              motionTime = millis();
                            }
                            lastSensorState = sensorState;
                            //
                            boolean washerState = ((motionTime - lastMotionTime < ONE_MINUTE * 2) && (motionTime - millis() < ONE_MINUTE * 5)); 
                            if (washerState != lastWasherState)
                            {
                              gw.send(msg.set(washerState));
                              Serial.print(F("Washer is "));
                              Serial.println(washerState? F("ON") : F("OFF"));
                            }
                            lastWasherState = sensorState;
                          }
                          
                          Moshe LivneM Offline
                          Moshe LivneM Offline
                          Moshe Livne
                          Hero Member
                          wrote on last edited by
                          #31

                          @BulldogLowell Alas, no. The sensors are on the edge of their capability, so you get some on, lots of off. an ON means a cycle started (I am not too worried about false positives from loading the machine for now. A quite period (no ON what so ever) of about 10 min means the cycle has finished. so basically its going to be eventually a very simple code like:

                          if (sensorState == ON)
                              cycleState=WASHING
                          else period check and if long enough then cycleState = ENDED
                          

                          I am still checking through different cycles and the kids do not produce enough dirty cloths, just to annoy me i think. Anyone has cloths he needs to wash?

                          1 Reply Last reply
                          0
                          • J Offline
                            J Offline
                            jasonrio
                            wrote on last edited by
                            #32

                            I bought one this year and i am really happy with it.

                            1 Reply Last reply
                            0
                            Reply
                            • Reply as topic
                            Log in to reply
                            • Oldest to Newest
                            • Newest to Oldest
                            • Most Votes


                            20

                            Online

                            11.7k

                            Users

                            11.2k

                            Topics

                            113.1k

                            Posts


                            Copyright 2025 TBD   |   Forum Guidelines   |   Privacy Policy   |   Terms of Service
                            • Login

                            • Don't have an account? Register

                            • Login or register to search.
                            • First post
                              Last post
                            0
                            • MySensors
                            • OpenHardware.io
                            • Categories
                            • Recent
                            • Tags
                            • Popular