Stove Monitor
Made by fskuok
Made by fskuok
Stove monitor supervises your stove when you are away; It can tell you: Is the stove on or not? What's the stove's temperature? How long has the stove been turned on?
Created: January 28th, 2015
Stove monitor supervises your stove when you are away;
It can tell you:
Is the stove on or not?
What's the stove's temperature?
How long has the stove been turned on?
Components:
Force Sensor x1
Temperature Sensor x1
10K Ohm Resistor x1
470 Ohm Resistor x2
Red LED x1
Green LED x1
10nF Capacitor x1
and
Jumper Wires...
/**********************
*
* Application Setup
*
**********************/
//if temperature sensor's data is big then this, regard stove as on
int stoveOnTemp = 21;
//if has been on longer then this (milliseconds), send a alert
int alertAfterMs = 10000;
/**********************
*
* Main code
*
**********************/
//pins
int sensorIndicateLED = D0;
int stoveIndicateLED = D1;
int tempSensor = A0;
int presSensor = A1;
int counter = 0;
bool sensorOn;
int stoveOn;
unsigned long stoveOnTime;
unsigned long stoveOnMs;
bool alertSent = false;
int tempReading;
double temperature;
void setup(){
//set pins
pinMode(sensorIndicateLED, OUTPUT);
pinMode(stoveIndicateLED, OUTPUT);
pinMode(tempSensor, INPUT);
pinMode(presSensor, INPUT);
//expose variables
Spark.variable("stoveOn", &stoveOn, INT);
Spark.variable("stoveOnMs", &stoveOnMs, INT);
Spark.variable("temperature", &temperature, DOUBLE);
initValues();
}
/**********************
*
* Main Loop
*
**********************/
void loop(){
//if switch the sensor on/off through force sensor
if(analogRead(presSensor) > 1000){
//change sensor on/off
sensorOn = !sensorOn;
//if deactivate sensor, init all values
if(!sensorOn){
initValues();
//if activate sensor, flash LED once as feed back
}else{
digitalWrite(sensorIndicateLED, HIGH);
delay(100);
digitalWrite(sensorIndicateLED, LOW);
}
//delay to prevent iterating switch on/off sensor
delay(1000);
}
if(sensorOn){
//update temperature variable
tempReading = getTemp(tempSensor);
//flash LED to indicate data reading
digitalWrite(sensorIndicateLED, HIGH);
delay(100);
digitalWrite(sensorIndicateLED, LOW);
//if the stove on
if(temperature > stoveOnTemp){
digitalWrite(stoveIndicateLED, HIGH);
//if stove is just turned on
if(stoveOn == 0){
//record turn on time
stoveOnTime = millis();
//set stove status variable
stoveOn = 1;
//if stove is already on
}else{
//calculate how long has the stove been turned on
stoveOnMs = millis() - stoveOnTime;
//if the stove is turned on for too long
if(stoveOnMs > alertAfterMs){
//start to flash alert LED
digitalWrite(stoveIndicateLED, counter%2 ? HIGH : LOW);
//if hasn't sent alert, send a alert SMS using IFTTT
if(!alertSent){
Spark.publish("StoveOnTooLongAlert", "alert");
alertSent = true;
}
}
}
//if the stove off
}else{
initValues();
digitalWrite(stoveIndicateLED, LOW);
}
delay(1000);
counter++;
}
}
/**********************
*
* function declarations
*
**********************/
void initValues(){
alertSent = false;
stoveOn = 0;
stoveOnTime = 0;
stoveOnMs = 0;
}
double getTemp(int tempSensorPin){
return ((analogRead(tempSensorPin) * 3.3) / 4095.0 - 0.5) * 100;
}
Click to Expand
stoveMonitor from Fan Sai Kuok on Vimeo.
Stove monitor supervises your stove when you are away;
It can tell you:
Is the stove on or not?
What's the stove's temperature?
How long has the stove been turned on?