JordanThomas LyonsMatthew Lucke
Published

MEGR 3171 Home Monitoring System

A home-based disaster detection and monitoring system for fire, flood, temperature, and humidity.

BeginnerFull instructions provided2 hours140
MEGR 3171 Home Monitoring System

Things used in this project

Hardware components

Argon
Particle Argon
×3
LED (generic)
LED (generic)
Clear LED from Argon Kit
×3
Resistor 220 ohm
Resistor 220 ohm
×3
Elegoo Flame Sensor
Elegoo 37 Sensor Kit V2
×1
Elegoo Water Level Sensor
Elegoo 37 Sensor Kit V2
×1
DHT11 Temperature & Humidity Sensor (3 pins)
DHT11 Temperature & Humidity Sensor (3 pins)
Elegoo 37 Sensor Kit V2
×1
Buzzer
Buzzer
Active Buzzer - Elegoo 37 Sensor Kit V2
×1

Software apps and online services

Particle Build Web IDE
Particle Build Web IDE
ThingSpeak API
ThingSpeak API
Maker service
IFTTT Maker service
Telegram Messenger

Story

Read more

Schematics

Fire Detect Circuit

Water Level Circuit

Temperature/Humidity Circuit

Code

Fire Detection

Arduino
int sensor = A5;        //Pin Declaration
int buzzer = D6;        //Pin Declaration
int status = D7;        //Pin Declaration
int LED_PIN = D2;

int detect = 0;         //Pin Data

bool fire = false;      //Flag
bool buzz = false;      //Flag

void setup() {
    pinMode(LED_PIN, OUTPUT);
    Serial.begin(9600);                                         //Has to do with hardware ports
    pinMode(sensor, INPUT);                                     //Pin Setup
    pinMode(buzzer, OUTPUT);                                    //Pin Setup
    pinMode(status, OUTPUT);                                    //Pin Setup
    Particle.variable("detect", detect);                        //allows me to read the value of detect from CMD prompt
    Particle.subscribe("Temperature_Lyons", myHandler, MY_DEVICES);
}

void myHandler(const char *event, const char *data){
    digitalWrite(LED_PIN,HIGH);
    delay(2000);
    digitalWrite(LED_PIN,LOW);
    }
    
void loop() {
    detect = analogRead(sensor);                                //Get input from sensor
    if(detect <= 2900 && fire == false){                        //If sensor reads fire and there wasn't a fire last clock cycle
        String num = String(detect);                            //Converts int to string so it can be published
        digitalWrite(buzzer, HIGH);                             //Turn on the alarm
        digitalWrite(status, HIGH);                             //Turn on the D7 LED
        fire = true;                                            //Set the Fire Flag to True
        Particle.publish("Fire_Detected", "fire", PRIVATE);     //Let the other Particle know there was a fire
        Particle.publish("Fire_Value", String(detect), PRIVATE);           //Give ThingSpeak a value to graph
        delay(2000);                                            //Prevents overflow of publish events
    }else if(buzz == true && fire == true){                     //If there is still a fire and you have been told to buzz off
        digitalWrite(buzzer, LOW);                              //Turn off the alarm
        buzz = false;
    }
    
    if(fire == true && detect >= 2900){                         //If no fire
        Particle.publish("Fire_Not_Detected", "nofire", PRIVATE);   //Let the other Particle know there was a fire
        digitalWrite(buzzer, LOW);                              //Turn off the alarm
        digitalWrite(status, LOW);                              //Turn off the D7 LED
        fire = false;                                           //Set the Fire Flag to False
    }
}

Water Detection

Arduino
const int WATER_SENSOR_A_PIN = A0;
const int LED_PIN = D7;


void setup() {
    pinMode(LED_PIN, OUTPUT);
     Particle.subscribe("Temperature_Lyons", myHandler, MY_DEVICES);
}  

void myHandler(const char *event, const char *data){
    digitalWrite(LED_PIN,HIGH);
    delay(2000);
    digitalWrite(LED_PIN,LOW);
    }

void loop() {
    
        
        // read the water level from the sensor; convert to a voltage value
        int waterLevelA;
        float waterSensorVoltageA;
        String publishedData;
        
        waterLevelA = analogRead(WATER_SENSOR_A_PIN);
    
        waterSensorVoltageA = ((float)waterLevelA * 3.3) / 4095;
        
        if(waterSensorVoltageA >=1){
           Particle.publish("H20_Lyons", "WATER", PRIVATE); 
        }
        if(waterSensorVoltageA <=1){
            Particle.publish("No_H20_Lyons", "NO_WATER", PRIVATE);
        }
        delay(10000);
    }

Temperature and Humidity

Arduino
For addition libraries needed, search for GROVE_TEMPERATURE_AND_HUMIDITY_SENSOR
#include <Seeed_DHT11.h>

#define DHTPIN 	A2     // set pin

DHT dht(DHTPIN);

int led = D7;

void setup()
{
  pinMode(led, OUTPUT);
  digitalWrite(led, LOW);
  dht.begin();
  Particle.subscribe("Fire_Detected", myHandler, MY_DEVICES);
  Particle.subscribe("Fire_Not_Detected", myHandler1, MY_DEVICES);
  Particle.subscribe("H20_Lyons", myHandler2, MY_DEVICES);
  Particle.subscribe("No_H20_Lyons", myHandler3, MY_DEVICES);
}

void myHandler(const char *event, const char *data){
    digitalWrite(led,HIGH);
    }

void myHandler1(const char *event, const char *data){
    digitalWrite(led,LOW);
    }

void myHandler2(const char *event, const char *data){
    digitalWrite(led,HIGH);
    }

void myHandler3(const char *event, const char *data){
    digitalWrite(led,LOW);
    }


void loop()
{
    //Read Humidity
    float h = dht.getHumidity();
    // Read temperature as Celsius
    float t = dht.getTempCelcius();
    // Read temperature as Farenheit
    float f = dht.getTempFarenheit();
    
    // Check if any reads failed
    if (isnan(h) || isnan(t) || isnan(f))
    {
    	Serial.println("Failed to read from DHT11 sensor!");
    	return;
    }
   
    //trigger ThingSpeak
    Particle.publish("Temperature_Lyons", String(f), PRIVATE);
    Particle.publish("Humidity_Lyons", String(h), PRIVATE);
    
    
    delay(60000);
}

Credits

Jordan

Jordan

1 project • 2 followers
Thomas Lyons

Thomas Lyons

1 project • 2 followers
Matthew Lucke

Matthew Lucke

1 project • 2 followers

Comments

Add projectSign up / Login