Washready

Made by Jonathan Dyer

Introducing Washready™, the retrofit solution to all washing machine related roommate tension. Washready™ uses an accelerometer to register the vibration of the washing machine and sends the user a text reading “The washing machine is done. Go get your clothes before your roommates throw it on the floor!”, ensuring that the only clothes a roommate takes out of the washer are his own.

Created: February 2nd, 2017

0

Intention

I, as many others in the Greater Pittsburgh area live in an apartment where the washroom is on the bottom floor of my house. I am also very forgetful and leave my clothes in the washing machine often. As such, my friends often come all the way down 3 flights of stairs to discover that my clothes are still in the washer or dyer (sometimes both lol). It’s caused a bit of tension between my roommates and they often just throw my clothes on the floor beside the washer. I figured there has got to be a better way…

0

Context

Introducing Washready™, the retrofit solution to all washing machine related roommate tension. Washready™ uses an accelerometer to register the vibration of the washing machine and sends the user a text reading “The washing machine is done. Go get your clothes before your roommates throw it on the floor!”, ensuring that the only clothes a roommate takes out of the washer are his own. 

0

Process

There were four levels to completion of our project: Basic - Status Indicator, Intermediate - Sensor Feedback, Advanced - Visual Alerts and Expert - Connect to the cloud by a remote alert. 

For the basic status indicator my goal was to blink a light when the sensor was collecting data. This included just a LED, accelerometer, photon and pushbutton. A few comments were that the LED turned out to be more of a task than I expected because I had to learn how to blink the LED without delay because the delay messed up the sampling rate of the accelerometer. Also, calibrating the accelerometer took a lot trial and error. 

Next I added another LED to the system that adjusted the brightness based upon how high the accelerometer reading was. For this I had to characterize the accelerometer (I shook the accelerometer as much as possible to register a maximum value) and I used the map function to take the accelerometer data and turn it into numbers that I could register on the PWM range. 

For the advanced level, I added a light that blinked three times to indicate that the cycle was finished. This was the largest coding task as the logic to register when the washer was done had to be developed and because it's linked to the shaking of the accelerometer I had to account for the edge cases: the sensor getting tapped accidentally and a random drop in the amount of shaking while the washer was on. To handle the first edge case, I used a wrote a function for a simple low-pass filter to make the system less responsive to major changes. The filter required some tuning (i.e. determining the value of alpha [see code]). The value also became a float when used in the filter which prevented the sensor feedback light from working so I pass the int function to the result of the filter in every loop. The second edge case was covered in the regular loop using boolean values for “on” and “delay” to ensure that only significant changes were registered 

Finally , for the expert level I had the photon send me a text when it registered that the cycle was finished. I used “If this then that” to send a text message to my phone once the cycle was registered finish. Using “if this then that” required understanding how Particle.publish worked but once that was accomplished it was relatively easy to add into the rest of the code 

 


     

    0

    Product

    Despite a few bugs the project was able to make it all the way to the expert round and demonstrate functionality. It can send a text after it has registered the equivalent of “being finished”. The functionality only served as a “proof of concept” because I could not bring a washing machine to class. The next stage would be to replace the button with a correlation to the actual systems within the washing machine (i.e. the on/off dial) to allow the user to not even think about the washer. This way, I would never forget to turn it on.   

    0

    Reflection

    While my professor called this project a “low-hanging fruit” it turned out to be a difficult task because of all the different lessons I had to learn. I had to calibrate the sensor, research and create a low-pass filter and create the logic for on and off , etc… In this way, the project was a great learning experience and it taught me a lot. However, for my next projects, I am going to air on the side of increased complexity and difficulty because it made me realize that no matter what project you do, there will be a lot of work that has to be done. 

    0
    //Variables to control blinking for status indicator
    const int ledPin = D0;
    int ledState = LOW;
    unsigned long previousMillis = 0;
    const long interval = 1000; //interval at which to blink the LED
    
    //variabless for sensor feedback
    const int sensePin = D1;
    int PWM = 0;
    
    //Holds GND and 5V pins of accelerometer
    const int gndPin = A0;
    const int powerPin = A4;
    
    //Pin of x axis on the accelerometer
    const int xPin = A3;
    
    //Variables to take time into account
    long t1 = 0;
    long t2 = 0;
    bool delayState = false;
    int dt = 1000;
    
    //variables for low pass filter
    int x = 0;
    int x1 = 0;
    int x2 = 0;
    float y1 = 0;
    float y2 = 0;
    int y2int = 0;
    float alpha = .05; //value for low pass
    
    //Values to tell whether the washer is on
    bool on = FALSE;
    int onPin = D2;
    bool washing_machine = false;
    
    //control switch
    int switchPin = D3;
    int switchState = LOW;
    int reading;
    long t; //helps to prevent switch bounce
    long debounce = 200; //time interval for how often the pin is checked
    int previous =HIGH;
    
    
    void setup(){
      //this method for linking the DXL325 accelerometer can be found on their website
      pinMode(gndPin, OUTPUT);
      pinMode(powerPin,OUTPUT);
      digitalWrite(gndPin, LOW);
      digitalWrite(powerPin, HIGH);
      //Starting Serial to use for debugging
      Serial.begin(9600);
      // lone input: off/on switch
      pinMode(switchPin,INPUT);
      //setting outputs
      pinMode(ledPin, OUTPUT);
      pinMode(sensePin, OUTPUT);
      pinMode(onPin, OUTPUT);
    
    }
    
    void filter(){
      x = analogRead(xPin) - 2037; //accounting for gravity offset
      x2 = map(abs(x),0,400,0,255); //mapping sensor data to PWM
      y2 = (y1 + alpha*(x2 - y1)); //algorithm found on wikipedia
      y1 = y2;
      x1 = x2;
      y2int = int(y2); //converting result to integer to pass to PWM
      analogWrite(sensePin, y2int); // controls light to correlate to how much shaking
      delay(100);
    }
    void loop(){
      reading = digitalRead(switchPin);
      if (reading == LOW && previous == HIGH && millis() - t > debounce) {
        if (switchState == HIGH)
          switchState = LOW;
        else
          switchState = HIGH;
        t = millis();
      }
      previous = reading;
      Serial.print(" switchState:");
      Serial.println(switchState);
      if (switchState == HIGH){
        filter();
        Serial.print(" y2int:");
        Serial.println(y2int);
        if (y2int > 20)
          {on = TRUE;}
        if (on == TRUE && y2int < 10){
          if(!delayState)  {
            t1 = millis();
            delayState = true;
            Serial.print(" delaying ");
          }
          else {
            t2 = millis() - t1;
            if (t2 > dt) {
              Serial.print(" time elapsed ");
              if (y2int < 10) {
                for (int i = 0; i< 3; i++) {
                  digitalWrite(onPin, HIGH);
                  delay(500);
                  digitalWrite(onPin, LOW);
                  delay(500);
                  }
                  on = FALSE;
                  Particle.publish("done!");
                  Serial.println(" done ");
                }
              else {
                  Serial.println(" still shaking ");
                }
                delayState = false;
                Serial.println(" delaying ");
              }
            }
          }
      //function for blinking LED without delay
      unsigned long currentMillis = millis();
      if (currentMillis - previousMillis >= interval) {
        // save the last time LED blinked
        previousMillis = currentMillis;
        // if the LED is off turn it on and vice-versa:
        if (ledState == LOW) {
          ledState = HIGH;
        } else {
          ledState = LOW;
        }
        digitalWrite(ledPin, ledState);
      }
      }
    }
    Click to Expand
    x
    Share this Project


    Focused on
    About

    Introducing Washready™, the retrofit solution to all washing machine related roommate tension. Washready™ uses an accelerometer to register the vibration of the washing machine and sends the user a text reading “The washing machine is done. Go get your clothes before your roommates throw it on the floor!”, ensuring that the only clothes a roommate takes out of the washer are his own.