Is my house on fire?
Made by Jesse Park
Made by Jesse Park
No, this doesn't let you know if you're house is on fire. But it does notify you if your stove is on while you are away to prevent that from happening!
Created: January 28th, 2016
The code pushes the notification to my smart phone when the stove is turned on through IFTT (left picture). When the oven is on, the LED light starts to get brighter to indicate the duration of the time. After 10 minutes, the beeper is activated to warn the user that the stove has been on for a long time. At any time when the beeper is activated, the user can press the push button to delay the beeping for another 10 minutes (middle picture). This feature allows the roommate outside the house know that there is a person near the stove. Once the stove is turned off, IFTT sends another notification to my smart phone (right picture).
// By Jesse Park
// 1/28/16
// This code makes the stove smarter
// Set the variables
int hallpin = A0; // hall effect sensor pin
int ledpin = D0; // led pin
int beeppin = D1; // beeper pin
int buttonpin = D2; // button pin
int hallEffectValue = 0; // value of the hall effect sensor
int ledbrightness = 0; // control the led brightness
int long timer = 0; // control time
int beep = 0; // loudness of the beeper
int duration = 0; // records how long the stove is on
int pushbuttonstate = 0; // shows the state of the push button
int ifttHallEffectValue = 0; // special variable to work with IFTT
// Set up
void setup() {
Serial.begin(9600); // for easy debugging
pinMode(ledpin, OUTPUT); // set ledpin as an OUTPUT
pinMode(buttonpin, INPUT_PULLUP); // set buttonpin as an INPUT_PULLUP
pinMode(beeppin,OUTPUT); // set beeppin as an OUTPUT
}
// Set the loop
void loop() {
hallEffectValue = analogRead(hallpin); // set the hall effect sensor
pushbuttonstate = digitalRead(buttonpin); // set the value of the pushbuttonstate
// Activates when the stove is on
if (hallEffectValue > 100){
// Used for publishing data to IFTT. Checks if the hall effect value has changed
if (ifttHallEffectValue == 0){
ifttHallEffectValue = 1; // set the hall effect value to 1
Particle.publish("onStatus", "ON"); //sends an event that the stove is on
}
ifttHallEffectValue = 1; // set the hall effect value to 1
// set time function
if( timer == 0 ){
timer = millis();
}
// Changes the brightness depending on time
if (ledbrightness < 255){
ledbrightness = ledbrightness + 1;
}
else ledbrightness = 255;
analogWrite(ledpin,ledbrightness); //record the brightness
// Checks if 10 min has passed. If so, beeps untill pushbutton is pressed
if (timer + 600000 < millis() ) {
analogWrite(beeppin, 1);
duration = duration + 1;
if (pushbuttonstate == LOW) {
timer = 0; //restart time
analogWrite(beeppin, 0);
duration = 0;
Particle.publish("PushButton", "Delay"); //sends an event that the button is pressed
}
}
else duration = duration + 1;
}
// If the stove is not on, the stove is off.
else {
// Used for publishing data to IFTT. Checks if the hall effect value has changed
if (ifttHallEffectValue == 1){
ifttHallEffectValue = 0;
Particle.publish("offStatus", "OFF"); //sends an event that the stove is off
}
ifttHallEffectValue = 0;
timer = 0; //restart time
ledbrightness = 0;
duration = 0;
analogWrite(ledpin,ledbrightness); //turn off the led
analogWrite(beeppin, 0);
}
// Used for debugging
Serial.print( "HallEffect " );
Serial.println( hallEffectValue);
Serial.print( "LED " );
Serial.println( ledbrightness );
Serial.print( "Timer " );
Serial.println( timer );
Serial.print( "Duration " );
Serial.println( duration );
delay(1000);
}
Click to Expand
This course charts the emergence of the now "connected world" to explore the possibilities for future products and connected spaces.
No, this doesn't let you know if you're house is on fire. But it does notify you if your stove is on while you are away to prevent that from happening!