Erik StewartJesse Icenhour
Published

Washer/Dryer Timer and Update

Don't ever forget your clothes in the washing machine or dryer again. A simple IoT setup will make sure you are reminded immediately.

IntermediateFull instructions provided2 hours881
Washer/Dryer Timer and Update

Things used in this project

Story

Read more

Schematics

Circuit Diagram

The circuit diagrams were the same for each photon used. The circuit simply consisted of two roller switches, jumper wires, and a photon. One switch was wired to ground and to pin D0. The second switch was wired to ground and to pin D2. The photon was also wired to ground. This simple circuit allowed for our photons to read input signals sent in from the roller switches in order to know when the washer/dryer cycles were started or ended.

Dry Time Statistics

This is a screenshot of the graph from thingspeak as the dryer is used multiple times. Allows the user to compare dry times of different size laundry loads. The time is measure in minutes and the horizontal axis shows the date and time when the dryer was used.

Actual Circuit

Wash Time Statistics

Screenshot of the thingspeak graphical UI that keeps track of the total wash time of the user. the vertical axis measures time in minutes and the horizontal axis shows the date and time when the wash cycle was completed.

Code

Wash Cycle Code

C/C++
This code is flashed to the photon connected to the washing machine. It subscribes to the dry time published by the dry time code and publishes it to the console. It takes the time difference between when the two switches were pressed, publishes it to the console, and also sends a notification that the wash cycle has been completed.
int ledPin = D1;       //utilizes pin D1 with an led for testing purposes
int ledPin2 = D3;      //utilizes pin D3 with an led for testing purposes

int switchPin = D0;    //utilizes pin D0
int switchPin2 = D2;   //utilizes pin D2

long start = 0UL;      //creates a variable called "start" and sets it equal to 0
long end = 0UL;        //creates a variable called "end" and sets it equal to 0
long WashTime= 0UL;    //creates a variable called "WashTime" and sets it equal to 0                            

char publishLong[40];  //allows the variables above to be published later on in the code                           

void setup()
{

 Particle.variable("time", WashTime);
  pinMode( switchPin , INPUT_PULLUP); 
  pinMode( switchPin2 , INPUT_PULLUP);
 

  pinMode( ledPin , OUTPUT ); 
  pinMode( ledPin2 , OUTPUT);
  
   Particle.subscribe("drytime",handler,"31001d001447353236343033");   //allows one photon to retrieve the published data from the other photon                                                                                                                                                                                   
}

void handler(const char *drytime, const char *DryTime) {   // Trigger the integration                                                                    
   
  Particle.publish("Dry Time", String(DryTime), PRIVATE);    //Publishes the data retrieved from line 23 to the console                                                                                                                               
  delay(5000);
  
}
void loop()
{ 
   int buttonState = digitalRead( switchPin );       //creates a variable called "buttonState" and assigns it to a pin on the photon                                                                                                                
  
   int buttonState2 = digitalRead( switchPin2 );     //creates a variable called "buttonState2" and assigns it to a pin on the photon                                                        
 if (buttonState == LOW )                            //initiates code when the first switch is pushed                                                          
  {
    
   start = millis();                                 //starts a timer
    digitalWrite( ledPin, HIGH);
    Particle.publish("washer has started");          //publishes an initiation message to the console                                                         
    delay(1000);
    
  }
  else{

    digitalWrite( ledPin, LOW);

  }
if( buttonState2 == LOW )                            //initiates code when the second switch is pressed                                                          
  {
  
  end = millis();                                    //starts a seperate timer
    digitalWrite( ledPin2, HIGH);                    //led lights up for testing purposes                                                        
  
  WashTime = (end - start);                          //takes the difference between the two timers to establish the time of the process                                                                                                                                                                           

Particle.publish("washtime", String(WashTime));      //publishes the time of the process to the console                                                        
delay(1000);

}
}

Dry Cycle Code

C/C++
This code is flashed to the photon connected to the dryer. It subscribes to the wash time from the wash cycle code and publishes it to the console. It takes the time difference between when the two switches were pressed, publishes it to the console, and also sends a notification that the dry cycle has been completed.
int ledPin = D1;          //utilizes pin D1 with an led for testing purposes
int ledPin2 = D3;         //utilizes pin D3 with an led for testing purposes

int switchPin = D0;       //utilizes pin D0
int switchPin2 = D2;      //utilizes pin D2

long start = 0UL;         //creates a variable called "start" and sets it equal to 0                             

long end = 0UL;           //creates a variable called "end" and sets it equal to 0                              

long DryTime= 0UL;        //creates a variable called "WashTime" and sets it equal to 0                                 

char publishLong[40];     //allows the variables above to be published later on in the code                              

void setup()
{

 Particle.variable("time", DryTime);
  pinMode( switchPin , INPUT_PULLUP); 
  pinMode( switchPin2 , INPUT_PULLUP);
 

  pinMode( ledPin , OUTPUT ); 
  pinMode( ledPin2 , OUTPUT);
  
   Particle.subscribe("washtime",handler,"2b001b000d47343438323536");   //allows one photon to retrieve the published data from the other photon                                                                                                                                                                                                                                                                                                                                                             
}

void handler(const char *washtime, const char *WashTime) {             // Trigger the integration                                                                   

  Particle.publish("Wash Time", String(WashTime), PRIVATE);           //Publishes the data retrieved from line 23 to the console                                                                                                                                                                                                                                                                                          
  delay(5000);
}

void loop()
{ 
   int buttonState = digitalRead( switchPin );                        //creates a variable called "buttonState" and assigns it to a pin on the photon                                                                                                                                                                                                                                                                       
   
   int buttonState2 = digitalRead( switchPin2 );                      //creates a variable called "buttonState2" and assigns it to a pin on the photon                                                                                                                                                                                                                                                                     

 if (buttonState == LOW )                                             //initiates code when the first switch is pushed                                                                                                                                 
  {
    
   start = millis();                                                  //starts a timer                                                                           
    digitalWrite( ledPin, HIGH);
    Particle.publish("dryer has started");                            //publishes an initiation message to the console                                                                                                                                 
    delay(1000);
    
  }
  else{

    digitalWrite( ledPin, LOW);

  }
if( buttonState2 == LOW )                                             //initiates code when the second switch is pressed                                                                                                                                                                                                                
  {
  
  end = millis();                                                     //starts a seperate timer                                                                    
  
    digitalWrite( ledPin2, HIGH);                               //led lights up for testing purposes                                                               
    
  DryTime = (end - start);                                            //takes the difference between the two timers to establish the time of the process                                                                                                                                                                                                                                                                     
  
Particle.publish("drytime", String(DryTime));                         //publishes the time of the process to the console                                                                                                                                   
delay(1000);
 
}

}

Credits

Erik Stewart

Erik Stewart

1 project • 0 followers
Machanical engineering student
Jesse Icenhour

Jesse Icenhour

2 projects • 0 followers

Comments