Adam CellonSamir Undavia
Published © Apache-2.0

Bare Conductive Leak Detector

Use Bare Conductive Electric Paint, an Arduino, and the anduinoWiFi shield to make a system that sends a text when a leak is detected!

IntermediateFull instructions provided2 hours6,231

Things used in this project

Story

Read more

Code

Anduino Leak Detector

Arduino
#include <WiFi101.h> 
#include "Adafruit_IO_Client.h" 

// WiFi 
#define WLAN_SSID  "YOUR_WIFI_SSID" 
#define WLAN_PASS  "YOUR_WIFI_PASSWORD" 
WiFiClient client;

// Adafruit IO 
#define AIO_KEY    "YOUR_ADAFRUIT_IO_KEY" 
Adafruit_IO_Client aio = Adafruit_IO_Client(client, AIO_KEY); 
Adafruit_IO_Feed adafruitFeed = aio.getFeed("Andium");

// Minimum voltage threshold 
float threshold = 4.0; 
float prevVoltage = 5.0; 
void setup() { 
 Serial.begin(9600); 
 delay(10); 
 Serial.println(); 
 Serial.println(); 
 Serial.println("Starting up the Anduino Leak Detector!");
 
 // Connect to WiFi 
 Serial.print("Connecting to "); 
 Serial.println(WLAN_SSID); 
 WiFi.begin(WLAN_SSID, WLAN_PASS); 
 while (WiFi.status() != WL_CONNECTED) { 
   delay(1000); 
   Serial.print("."); 
 } 
 Serial.println(); 
 Serial.println("WiFi connected"); 
 Serial.print("IP address: "); 
 Serial.println(WiFi.localIP());
 
 // Adafruit IO 
 aio.begin(); 
 Serial.println("Ready!"); 
}

void loop() { 
 Serial.println("Reading sensor value"); 
 int sensorValue = analogRead(A1); 
 float voltage = sensorValue * (5.0 / 1023.0);
 
 // Check to see if the circuit was connected and is now broken 
 if ((voltage < threshold) && (prevVoltage > threshold)) { 
   Serial.println("circuit broken"); 
   Serial.print("Current voltage: "); 
   Serial.println(voltage); 
   Serial.println(); 
   if (adafruitFeed.send("broken")) { 
     Serial.println("Wrote value to Adafruit feed: broken"); 
   } else { 
     Serial.println("Error writing value to Adafruit feed!"); 
   }
   
   // Wait while the leak is being fixed 
   Serial.println("Waiting 5 minutes"); 
   delay(300000); 
 }
 
 // Check to see if the circuit was broken and is now completed 
 else if ((voltage > threshold) && (prevVoltage < threshold)) { 
   Serial.println("circuit completed"); 
   Serial.print("Current voltage: "); 
   Serial.println(voltage); 
   Serial.println(); 
   if (adafruitFeed.send("completed")) { 
     Serial.println("Wrote value to Adafruit feed: completed"); 
   } else { 
     Serial.println("Error writing value to Adafruit feed!"); 
   } 
 }
 
 // Print the current voltage 
 else { 
   Serial.print("Current voltage: "); 
   Serial.println(voltage); 
 } 
 prevVoltage = voltage; 
 delay(500); 
} 

Credits

Adam Cellon

Adam Cellon

0 projects • 4 followers
Building and breaking (mostly breaking) things whenever I can.
Samir Undavia

Samir Undavia

0 projects • 1 follower
Thanks to Adafruit and Samir Undavia.

Comments