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 StartedHere'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 SetupThe 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 CodeOpen 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.
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).
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!
Comments
Please log in or sign up to comment.