A laundry bin that makes noise and lights up when full! No more forgetting to bring it to the laundry room. Can even monitor remotely!
Goal:
I am trying to create a simple sensing device that reminds someone who is used to throwing laundry in the bin and walking away that it is time to take the bin to the laundry room. For added convenience, in case the buzzer eventually dies, an event is published to the cloud so that a user can stay informed as to the level of laundry in the bin. The goal is to provide simple audio/visual feedback for non-tech-savvy users to prevent a recurring headache.
Process:Reflection:
I learned that despite the intimidating challenge of "hacking one's home" using the Internet of Things, it is not very difficult to do. A big challenge is in thinking of applications that are useful, usable, and desirable. In retrospect, I would have liked to get a bigger proximity sensor and mount it elsewhere (similar to the button), as well as choosing much smaller wires, since they can obscure the sensor. The large wiring simply gets in the way of the sensor. I thought about using light instead of proximity but because some clothing has reflective elements, I'd need it pointed at a light source on the opposite side of the bin to measure when that value was broken, which is battery-intensive. Since my parents are not exceptionally tech-savvy, it would probably be more familiar to them to have a text sent to their phone or an email to their computer instead of monitoring events in the cloud.
Bill of Parts
ITEM |
QTY |
Particle Photon |
1 |
Proximity Sensor QRD1114 |
1 |
LED, standard |
1 |
220Ω Resistor |
2 |
10K Resistor |
1 |
Buzzer |
1 |
Push Button |
1 |
/*
* Project homehack
* Description: Laundry basket that determines when it is full and publishes event
* Author: Ben Fisher
* Date: 1/29/18
*/
int ledPin = D0; // Establish pin for the LED
int proxPin = A0; // Establish input pin for proximity sensor
int buzzPin = D2; // Establish input pin for piezo buzzer
int buttonPin= D3; // Establish input pin for reset button
int val = 0; // Variable for reading the pin status
int this_sensor=0; // Used for delay between sensor occurrences
int proxTriggerFlag=0;
int binIsFullTimeDelay=3000; // how many milliseconds the sensor stays active before reporting that the bag is full
// this must be longer than the wait to update the sensor info
bool isLoading = false;
// Track if it's on or off
bool appState = true;
int alarmLength = 3000; // max length of alarm if button is not pressed in time
// setup() runs once, when the device is first turned on.
void setup() {
// Put initialization like pinMode and begin functions here.
pinMode(ledPin, OUTPUT); // declare LED as output
pinMode(buzzPin, OUTPUT); // declare sensor as input
pinMode(proxPin, INPUT); // declare sensor as input
pinMode( buttonPin, INPUT_PULLUP); // sets pin as input
Serial.begin(9600);
}
void checkIfButtonIsOff() {
int alarmStart = millis();
checkAgain: // can we do this without goto or recursion?
int buttonState = digitalRead( buttonPin );
appState = buttonState;
if( !appState ){
digitalWrite(buzzPin, LOW); // button is correct; turn alarm off
}else{
if (millis()-alarmStart>=alarmLength){
digitalWrite(buzzPin, LOW);
}else{
delay(500); //check again in 1/2 second
goto checkAgain;
}
}
}
// loop() runs over and over again, as quickly as it can execute.
void loop() {
// The core of your code will likely live here.
val = analogRead(proxPin); // read input value
Particle.variable("val",&val,INT);
Particle.variable("this_sensor",&this_sensor,INT);
// blink new LED for 100 ms to indicate that sensor data was published
delay(100);
if (val <= 2000) { // check if the input is HIGH
digitalWrite(ledPin, HIGH); // turn LED ON
delay(100); //led test only, remove later
digitalWrite(ledPin, LOW); // turn LED ON
delay(100); //led test only, remove later
// implement a wait to ensure that any falling clothes don't trigger "full"
// just because they pass the sensor
// Is this the first time that this_sensor was triggered?
if (this_sensor==0){
this_sensor = millis(); //now we know when it is first active.
}
if (abs(millis()-this_sensor)>=binIsFullTimeDelay && proxTriggerFlag==1){
//then the trigger has been active for the binIsFullTimeDelay
// sound the alarm!
digitalWrite(buzzPin, HIGH);
delay(500); // useful in case button is faulty
// The alarm is going off; it's up to the user to push the reset button
// or wait for alarmLength to expire
checkIfButtonIsOff();
// Whether the button is pushed or the timer expires, publish an event
Particle.publish("Laundry is Full!", PRIVATE); //Publish event (console)
this_sensor=0; // Used to reset timer for next proximity sensor trigger
}
digitalWrite(ledPin, LOW); // keep LED OFF
proxTriggerFlag=1; // record flag that proximity sensor was triggered
}else{
proxTriggerFlag=0; // prevents two completely separate occurrences from
// triggering the "laundry is full" loop
// (only continuous triggering will keep the flag = 1)
this_sensor=0;
}
// wait 1s before retrieving data again (per assignment)
delay(1000);
}
13.330 KB · Download / View
A hands-on introductory course exploring the Internet of Things and connected product experiences.
A laundry bin that makes noise and lights up when full! No more forgetting to bring it to the laundry room. Can even monitor remotely!
January 25th, 2018