Liam LawlessNicholas HoskinAJ Rutherford
Published

Home Energy Saving Email Alert System

Sensors will check to see if you have left the lights on and if the temperature is where you want it when you leave the house.

IntermediateShowcase (no instructions)12
Home Energy Saving Email Alert System

Things used in this project

Hardware components

Breadboard (generic)
Breadboard (generic)
×3
Argon
Particle Argon
×3
Elegoo 37 Sensor Kit V2.0
Used the Big Sound, the Digital Temperature, and the Photo-Resistor
×1
Jumper wires (generic)
Jumper wires (generic)
×10

Software apps and online services

Particle Build Web IDE
Particle Build Web IDE
Fritzing
Google Sheets
Google Sheets

Story

Read more

Schematics

Big Sound Sensor

Measures the amount of sound in a room.

Photoresistor

Measures the amount of surrounding light.

Digital Temperature Sensor

Measures the surrounding air temperature.

Code

Digital Temperature Sensor Code

C/C++
#include <math.h>
#include <cmath>
#include <string>

int tempD = 1;
float tempA = A2;
SYSTEM_THREAD(ENABLED);

void setup() {
  pinMode(tempD, INPUT);
  pinMode(tempA, INPUT);
  Particle.subscribe("Front Door", SoundFalse, MY_DEVICES);
}

void loop() {}


void SoundFalse(const char *event, const char *data) {
  int Atemp = 0;
  int AvgT;
  int z = 30;
  int Asum = 0;
  int temp;
  float Atempf = analogRead(tempA);
  for (int i=0; i<(z * 4); i++) {
    Atempf = analogRead(tempA);
    Atemp = round(Atempf);
    Asum = Asum + Atemp;
    delay(250);
  }
  AvgT = Asum/(z*4);
  Particle.publish("TempAvg", String(AvgT));
  if (AvgT < 1520) {
    Particle.publish("TempHigh", "high");
  } else if (AvgT > 1700) {
    Particle.publish("TempLow", "low");
  } else {
    Particle.publish("Good", "good");
  }
  
    for (int i=0; i<10; i++) {
      int Atemp = 0;
      int AvgT;
      int z = 1*60;
      int Asum = 0;
      int temp;
      float Atempf = analogRead(tempA);
      for (int i=0; i<(z * 4); i++) {
        Atempf = analogRead(tempA);
        Atemp = round(Atempf);
        Asum = Asum + Atemp;
        delay(250);
      }
      AvgT = Asum/(z*4);
      Particle.publish("TempAvg", String(AvgT));
    }
}

Photo-Resistor Code

C/C++
#include <math.h>
#include <Particle.h>
#include <cmath>
#include <string>

int sensorPin = A0;                                      
int sensorValue = 0;                                     
int X = 0;                                              

    
void setup() 

{
  pinMode(sensorPin, OUTPUT);                          
  Serial.begin(9600);
  
  Particle.subscribe("Front Door", soundCode, MY_DEVICES);
}


void loop()
{}

void soundCode(const char *event, const char *data)

{
    sensorValue = analogRead(sensorPin);
    analogWrite(X, sensorValue/4);
    
    delay(sensorValue);                                
    Serial.println(sensorValue, DEC);                
    
    int threshold = 130;
    X = analogRead(sensorPin);
    
  if (X > threshold) 
  {                                            
    Particle.publish("1LightsOn", "Lights are on");
        delay(1000);    
        }                                         
    else 
    {}
}

Big Sound Sensor Code

C/C++
#include <math.h>
#include <cmath>

int Sound = 3;

SYSTEM_THREAD(ENABLED); 

void setup() 
{
    pinMode(Sound, INPUT);
    Particle.subscribe("TempHigh", HighTemp, MY_DEVICES);
    Particle.subscribe("TempLow", LowTemp, MY_DEVICES);
    Particle.subscribe("1LightsOn", Light, MY_DEVICES);
}

void loop()
{
    int FrontDoor = 0;
    FrontDoor = digitalRead(Sound);


    if (FrontDoor == 1)
    {
        Particle.publish("Front Door", "Someone Opened The Front Door");
        delay(1000);
    }
}

void HighTemp(const char *event, const char *data) {
    Particle.publish("HighTemp");
}

void LowTemp(const char *event, const char *data) {
    Particle.publish("LowTemp");
}

void Light(const char *event, const char *data) {
    Particle.publish("Light");
}

Credits

Liam Lawless

Liam Lawless

0 projects • 0 followers
Nicholas Hoskin

Nicholas Hoskin

0 projects • 0 followers
AJ Rutherford

AJ Rutherford

0 projects • 0 followers

Comments

Add projectSign up / Login