jared yantosikThomas Guffey
Published © GPL3+

Flood Detection System

A notification system that will alert you when water is detected in any area of your home.

BeginnerFull instructions provided3 hours2,239
Flood Detection System

Things used in this project

Story

Read more

Schematics

Water Detection System Circuit

This schematic depicts the circuit and setup required to be able to detect water with the Particle Photon. The circuit involves two wires. The first wire is connected to D0 and the second wire is connected to GND. The opposite end of the two wires are positioned near each other in the area you wish to detect water presence at. When the ends of both wires are simultaneously submerged in water the circuit is completed. The particle is setup to detect and publish when the circuit is completed.

Code

Flood Detection

C/C++
The code below is used to publish an event of "Flood_status". The contents of the event are either "Hey! Your basement is flooding!" or "Your basement is not flooded!" When the flood is detected, a phone call is received using IFTTT.
int digitalvalue;

void setup() {
    
    pinMode(D7,OUTPUT);
    pinMode(D1,INPUT);
    
    Particle.variable("digitalvalue", &digitalvalue, INT);
    
    Particle.function("digitalvalue",digitalvalueToggle);

}

void loop() {
    
    digitalvalue = digitalRead(D1);
    
    delay(10000);
    
    if (digitalvalue==1) {
        Particle.publish("Flood_status","Hey! Your basement is flooding!");
        
    }
    else if (digitalvalue==0) {
        Particle.publish("Flood_status","Your basement is not flooded!");
    } 

}

int digitalvalueToggle(String command) {
    if (command=="on") {
        digitalWrite(D7,HIGH);
        return 1;
    }   
    else if (command=="off") {
        digitalWrite(D7,LOW);
        
        return 0;
    }
    else {
        return -1;
    }
}

LED Flash Transfer

C/C++
This code is used to turn on the D7 led on another particle to alarm the homeowner of a potential flood in their basement.
Int led = D7;

void setup() {
    
    pinMode(led, OUTPUT);
   // digitalWrite(led, LOW);
    
    Particle.subscribe("Flood_detected", light);
    
}

void light(const char *event, const char *data)
{
    if (strcmp(data,"Hey! Your basement is flooding!")==0){
    digitalWrite(led, HIGH);
    delay(5000);
    }
}

void loop() {
    
}

Credits

jared yantosik

jared yantosik

1 project • 0 followers
Thomas Guffey

Thomas Guffey

1 project • 0 followers

Comments