Project tutorial

Bare Conductive Leak Detector © Apache-2.0

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

  • 2,298 views
  • 2 comments
  • 8 respects

Components and supplies

Apps and online services

About this project

The Motivation

Picture this: you come home to a flooded kitchen - you know a pipe must be leaking, but which one? How long ago did it start? You could try to figure it out based on the size of the puddle that's definitely damaging your floor.... or you could make a leak detection system that sends you a text as soon as the leak starts!

We're going to use Bare Conductive Electric Paint to monitor any leakage. The electricity-conducting paint is water soluble - so a leak will wash it away! If we make a circuit with the paint and monitor whether it's closed or open using an Arduino, we'll be able to see exactly when the leak starts.

Getting Started

Here's what you need to get started:

  • Arduino Due
  • anduinoWiFi shield
  • Bare Conductive Electric Paint
  • A few jumpers wires to connect everything together
  • Electrical tape to secure the wires to the Bare Conductive Electric Paint

First, connect your anduinoWiFi shield to your Arduino Due. Then, connect three jumper wires to 5V, GND, and A1 on the shield.

Next, draw a thick layer of Bare Conductive Electric Paint on whatever it is that might start leaking. Secure the wires connected to 5V and GND to opposite sides of the line of paint. By doing this, we're making the closed circuit we'll be monitoring. Attach the wire connected to A1 near one end of the line - this is how we'll monitor the status of the circuit. To keep everything together, secure the wires with some electrical tape.

Essentially, the water soluble conductive paint is acting as a switch - when the leak washes away the paint, the switch opens! The wire connected to A1 will allow us to monitor the voltage across the paint, which should go to zero when the switch opens.

That's all the wiring needed to set up the leak detector!

Cloud Services Setup

The hardware is cool, but there's more that makes this project useful. As it stands, "monitoring" the leak means watching that voltage and waiting for it to drop. Let's make this project smart by sending our data to the cloud and getting a notification when the connection is broken!

First, let's set up all the cloud tools we need. Then we'll see how they all work together. To start, make a Twilio account and buy a phone number - this will allow us to send an SMS notification.

Next, make a Zapier account and create a Zap with a webhook trigger and Twilio action (Zapier will help us connect all the different cloud services together).

Make sure to save the webhook URL. You'll need this in a later step.

After completing the webhook trigger form, link your Twilio account and set up the Twilio message template. Fill in the "From Number" with your Twilio phone number and the "To Number" with the phone number that you want to receive the text message notification. Also fill in the "Message" field with a message that tells you that something's leaking.

Next, make an account at Adafruit.io and create a feed - this is the service that our Arduino will communicate with directly.

Lastly, create a trigger and enter the Zapier webhook URL in the trigger form.

Here's how these cloud tools are working together:

The Arduino sends a message to Adafruit IO. If the message Adafruit IO receives is "broken," Adafruit IO sends a message to the Zapier webhook. Once the Zapier webhook receives a message, it calls the Twilio API, which sends you a text message!

Currently, this setup only sends a text message if the circuit is broken. If you want to receive a text message if the leak is repaired, make another Adafruit IO trigger and Zapier Zap, replacing "broken" with "completed."

The Code

Open the Arduino IDE and make sure you have the Adafruit IO Arduino and WiFi101 (version 0.12.1) libraries installed.

Open up a new sketch and paste in the attached code. Make sure to use your own WiFi credentials and Adafruit IO key.

Adjust the voltage threshold to whatever works for your setup - when the voltage dips below this threshold, we'll consider the circuit broken.

// Minimum voltage threshold 
float threshold = 4.0; 

Every time the loop() method is run, the Arduino reads the current voltage across the conductive paint and compares the current voltage to the previous voltage to see if something in the circuit changed.

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)) { 
   // print the current voltage and send a message to Adafruit IO
}

If the previous voltage was above the threshold for having a complete circuit and the current voltage is below the threshold, send "broken" to Adafruit IO. (Why do we care about the previous voltage? Well, we only want ONE notification when the status changes from "connected" to "broken" - otherwise, once the circuit broke, we'd get messages until it was fixed!)

   if (adafruitFeed.send("broken")) { 
     Serial.println("Wrote value to Adafruit feed: broken"); 
   } else { 
     Serial.println("Error writing value to Adafruit feed!"); 
   }

This message then triggers the other cloud tools to send a text message.

Testing with Actual Leaks!

This is great in theory, but does it work with an actual leak? We tried it out two different ways to see whether the paint works the way we think it will. First, we put a thick line of paint around a PVC pipe and ran it under water - simulating a leak - to see how quickly it would wash away.

A pretty hefty leak... simulated.

It took a while for the thick line of paint to wash away; in fact, the wires came loose before the paint circuit was broken. Next, we decided to try a wider and thinner line of paint. This should give us similar conductivity but perhaps wash off a bit easier! This time, to make it more realistic, we put the line on a cup that we cut a hole into (in other words, we made a real leak).

Watch that paint wash away!

This confirms my suspicion - thinner paint will more readily wash away and allow our leak detection system to be more sensitive! Basically, we want the paint to be as thin as possible while still completing the monitoring circuit.

And That's It!

Find what you want to monitor, lay down your Bare Conductive paint, let it dry, then wire everything up. You'll receive a text message when the water soluble conductive paint is washed away!

Code

Anduino Leak DetectorArduino
#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); 
} 

Comments

Similar projects you might like

Pac-Man LED Pixel Panel Costume

Project tutorial by Ben Muller

  • 5,878 views
  • 4 comments
  • 96 respects

LoRa Gateway for DeviceHive

Project tutorial by DeviceHive IoT team

  • 1,518 views
  • 2 comments
  • 19 respects

Really Smart Box

Project tutorial by Stephen Harrison

  • 4,130 views
  • 2 comments
  • 15 respects

Raspberry Pi and Arduino Laptop

Project tutorial by Dante Roumega

  • 18,381 views
  • 6 comments
  • 45 respects

IoT Bird Feeder with Sigfox and Tweeter

Project showcase by Gaël Porté

  • 670 views
  • 0 comments
  • 9 respects
Add projectSign up / Login