Hackster is hosting Hackster Holidays, Ep. 4: Livestream & Giveaway Drawing. Start streaming on Wednesday!Stream Hackster Holidays, Ep. 4 on Wednesday!
Jakob IsleyEvan Morrison
Published

Washer Notifier

The washer notifier ensures that you and your roommates never argue over occupying the washer or dryer again.

IntermediateFull instructions provided671
Washer Notifier

Things used in this project

Hardware components

Argon
Particle Argon
×2
Arduino Noise Sensor
×1
LED (generic)
LED (generic)
×2
Breadboard (generic)
Breadboard (generic)
×2
Jumper wires (generic)
Jumper wires (generic)
×7

Software apps and online services

Particle Build Web IDE
Particle Build Web IDE

Story

Read more

Schematics

Noise Sensor

Receiver

Code

Sensor Code

C/C++
This code senses the noise level of the washing machine and sends either a 1 or a 0, depending on the high or low noise level. If the noise level is low(the washing machine is off) the led on board will turn off but if the noise level is high the led will remain off. It also receives a STOP or CONT function depending on what the other Argon receives.
#include <ThingSpeak.h>
int Dpin = D2; //Sound sensor input 
int val = 0; //Initial value of sound sensor
int indicator = D7; // Led output pin

void setup() {
    Particle.subscribe("Stop", ToggleSensorOff ,MY_DEVICES);
    Particle.subscribe("Cont", ToggleSensorOn , MY_DEVICES);
    pinMode (Dpin, INPUT);
    pinMode (indicator, OUTPUT);
    digitalWrite(indicator, HIGH);
}
void loop() {
    val = digitalRead(Dpin); // Reads the sound input
    if (val == LOW) {
    Particle.publish("Machine","1", PRIVATE); //Publishes that washing machine is off
    digitalWrite(indicator,HIGH); //Turns on led
    delay(1000); 
    }
    else if (val == HIGH) {
    Particle.publish("Machine","0", PRIVATE); //Publishes that washing machine is on 
    digitalWrite(indicator,LOW); //Turns off led
    delay(1000);
    }
}
void ToggleSensorOff(const char *topic, const char *data) {
    pinMode(Dpin, OUTPUT); //When "stop" is received the Dpin will become the output turning off the sound sensor as the input
    digitalWrite(indicator, LOW);
}
void ToggleSensorOn(const char *topic, const char *data) {
    pinMode(Dpin, INPUT); //When "Cont" is received the Dpin will continue to the the input 
    digitalWrite(indicator, HIGH);
}

Receiver

C/C++
This code receives the output from the Sensor Argon and interprets when to light up the led attached. It also had a subscribe function that will send "Cont" if the washing machine is still on and a "Stop" if the washing machine is off. This will leave the led on until the program is reset.
int LED = D4; //Led output pin
int val = 0;  //Initial value of led

void setup() {
Particle.subscribe("Machine",led_toggle,MY_DEVICES);
pinMode(LED, OUTPUT); 
}
void led_toggle(const char *topic, const char *data) {
}
void loop() {
    if ("Machine" == 0) { //If received data is 0 then light stays off
        digitalWrite(LED, LOW);
        delay(1000);
    }
    else if("Machine_on" != 0) { //If received data is a 1 then light turns on 
        digitalWrite(LED,HIGH);
        delay(1000);
    }
    else
        digitalWrite(LED,LOW); //If no data is received light stays off
        delay(1000);

    if (digitalRead(LED) == HIGH) { //If the led is on then "Stop" will be published
    Particle.publish("Stop", PRIVATE);
    delay(1000);
    }
    else if (digitalRead(LED) == LOW) { //If the led is on then "Cont" will be published 
    Particle.publish("Cont", PRIVATE);
    delay(1000);
    }
}

Credits

Jakob Isley

Jakob Isley

1 project • 1 follower
Evan Morrison

Evan Morrison

0 projects • 1 follower

Comments