Maggie WyattMarc Duemmler
Published

MEGR 3171 Oven Alarm

Forgot if you turned your oven off? Use this project to send an alarm if your oven is left on

BeginnerFull instructions provided523
MEGR 3171 Oven Alarm

Things used in this project

Hardware components

Photon
Particle Photon
×2
Thermistor 100K
×2
Resistor 100k ohm
Resistor 100k ohm
×2

Software apps and online services

Maker service
IFTTT Maker service
Google Sheets
Google Sheets

Story

Read more

Schematics

Photon Circuit

Photon Schematic

Code

Room Temp Sensor and Alarm

C/C++
This code measures the temperature of a room and publishes it. It then subscribes to the oven temprature code and will flash the led on and off.
// Declare variables and assign photon pins
int led=D7;
double thermistor= A0;//thermistor connected to pin D0
double roomtemp29; //room temperature
char publishString[40];

void setup() {
  // Initialize the outputs
  pinMode(led,OUTPUT);
  pinMode(thermistor, INPUT);
  // Power to led
  digitalWrite(led,LOW);
  
  Particle.variable("roomtemp29", roomtemp29);
}
void loop() {
  //read room temp
  roomtemp29 = analogRead(thermistor);
  
  //publish room temp
  bool success;
  success = Particle.publish("roomtemp29",publishString,PUBLIC);
  sprintf(publishString, "%1f", roomtemp29);
  // Subscibe to the event sent by the other photon
  delay(30000);
  Particle.subscribe("ovenTemp", ovenTempalarm);

}
// Code that tells the photon what to do in the event the event is published

void ovenTempalarm(const char *event, const char *data)
{
    if(strcmp(data,"hot")==0) {
  // Makes the photon blink thrice
digitalWrite(led,HIGH);
delay(5000);
digitalWrite(led,LOW);
delay(1000);
digitalWrite(led,HIGH);
delay(5000);
digitalWrite(led,LOW);
delay(1000);
digitalWrite(led,HIGH);
delay(5000);
digitalWrite(led,LOW);
delay(1000);
digitalWrite(led,HIGH);
delay(5000);
digitalWrite(led,LOW);
delay(1000);
digitalWrite(led,HIGH);
delay(5000);
digitalWrite(led,LOW);
delay(1000);
}
  else{
  }

}

Oven Temperature Sensor

C/C++
This codes subscribes to the room temperature of the first particle, compares it to the voltage drop over the resistor in series with oven thermistor. If the voltage drop over the oven resistor is greater than the voltage drop over the room temperature resistor it publishes 'hot' to the cloud. It also records the voltage over time in a google spreadsheet.
// Oven Temperature Sensor

double thermistor = A0; // The thermistor circuit will be connected to pin D0
double ovenvolt; // Voltage across thermistor in the oven
int roomtemp;
int i = 0;

void roomvolt(const char *event, const char *data)
{
  i++;
  roomtemp = atoi(data);
 //atof could work as well
 //Serial.print(i);
 //Serial.print(event);
 //Serial.print(", data: ");
 //if (data)
 //Serial.println(data);
 //else
 //Serial.println("NULL");
}

void setup() 
{
  pinMode(thermistor,INPUT);
  Particle.variable("temperature", ovenvolt); // Define variable for IFTTT
}

void loop() 
{
  Particle.subscribe("roomtemp29", roomvolt); // Subscribe to voltage across thermistor at room temperature
  delay(15000); // Delay 30 seconds
  ovenvolt = analogRead(thermistor); // Read voltage across thermistor in the oven

//If voltage across the thermistor in the oven is less than voltage across thermistor at room temperature, then the oven is hot
  if (ovenvolt-1000>roomtemp) { 
    Particle.publish("ovenTemp","hot", PUBLIC);
  }
  else {
    Particle.publish("ovenTemp","cold", PUBLIC);
  }
}

Credits

Maggie Wyatt

Maggie Wyatt

1 project • 0 followers
Marc Duemmler

Marc Duemmler

1 project • 0 followers

Comments

Add projectSign up / Login