msharmaAkhila Rao
Published © GPL3+

FloodNote: Smart Water Leak Detector

FloodNote: An end-to-end IoT solution to detect water leakage in your house or facility, and get notified.

IntermediateShowcase (no instructions)4 hours794
FloodNote: Smart Water Leak Detector

Story

Read more

Custom parts and enclosures

Demo video

Schematics

Circuit Image

Require: Particle Photon, LED, Buzzer, Wires, Resistors (100 Ohms)

Code

floodnote.ino

C/C++
Particle (.ino) file that you flash or write to your photon device.
#define INPUTPIN A0
#define BUZZER D0

#define FREQUENCY 1000
#define DELAY 500
#define PUB_DELAY 1000 // publish every 1s
#define THRESHOLD 4000

unsigned int last_publish = 0;
int analog_value = 0;

/** SETUP **/
void setup() {
    pinMode(INPUTPIN, INPUT);
    pinMode(BUZZER, OUTPUT);
}

/** LOOP **/
void loop() {
    unsigned long now = millis();
    if ((now - last_publish) < PUB_DELAY) {
        return;
    }

    analog_value = analogRead(INPUTPIN);
    
    if( analog_value < THRESHOLD ){
        
      Particle.publish("thingSpeakWrite_A0", "{ \"1\": \"" + String(analog_value) + "\" }", 60, PRIVATE);
      last_publish = now;
      
      tone(BUZZER, FREQUENCY); // Send 1KHz sound signal...
      delay(DELAY);
      noTone(BUZZER);          // Stop sound...
      
      delay(DELAY);   
    }
     noTone(BUZZER);   
}

Credits

msharma

msharma

1 project • 1 follower
Akhila Rao

Akhila Rao

1 project • 1 follower
Novice hacker!

Comments