Friday, 27 January 2017

Leak Detector for Underwater Camera

I've an underwater camera which doesn't have a vacuum system or leak detector and this scares the life out of me, especially when taking such expensive camera equipment underwater! So I had some bits lying around that could make a useful leak detector.

I've had a leak on a camera enclosure and strobe before and the only time you notice its flooded is when you go to use it and you see the water sloshing around inside! I'm not sure a detector is going to help that much but it's worth a try. 

Basically its an Arduino Pro Mini clone monitoring once a second, the water sensor via the ADC. When the sensor reports the presence of water, by returning a non-zero value, the audible alarm goes off and the on-board green LED starts to flash. The audible alert is quite load and can be heard from outside the enclosure. Power is supplied by two 2032 cells in series i.e. 6v.

The code is written using a low power library which means it consumes virtually no power between the 1 second polling activity.  I can't read the power consumption on my meter as its so low, so worst case its 10mA, so with two 2032 cells I think that provides ~600mAh so 60 hours? As there is a switch on the battery container, you can switch it off when not in use. 

The Arduino Pro Mini clone is programmed from the standard Arduino tool with the FTDI USB programmer but you could get a different board with built in USB interface like a Leonardo/Trinket/Lilypad but the Pro Minis are so cheap.

 Components:

Moisture Detector ( search ebay for "water detector arduino")
Passive Electronic Piezo Buzzer /Sounder 1-13V 
Pro Mini Atmega328P Board 5V 16M   ( look for cheapest 5v you can find)
6V Button Coin Cell Battery Holder Case Box With On-Off Switch CR2032

Circuit:


Code:

#include "LowPower.h"

int led = 13;
const int buzzerPin = 13;

// watch Board type, older ones are 5v,168 newer V2 ones are 5v,368

void setup() {
// initialize serial communication at 9600 bits per second:
Serial.begin(9600);

  pinMode(led, OUTPUT); 
  digitalWrite(led, LOW); 
  pinMode(buzzerPin, OUTPUT);
}


void loop() {
// read the input on analog pin 0:

     LowPower.powerDown(SLEEP_1S, ADC_OFF, BOD_OFF);    //Sleep 1 second
     
     //**************************************************************************************//
     //  Water Sensor Alarm
     
     int sensorValue = analogRead(A0); 

     //Serial.println(sensorValue); // Put this back in for debugging but remember to remove the lowpower call otherwise it won't work.
     
    if (sensorValue > 6)
    {  
      digitalWrite(led, HIGH);   // turn the LED on (HIGH is the voltage level)
      
      while (1) //Sound Alarm
      {
        digitalWrite(led, HIGH);
        tone ( buzzerPin , 523 , 200);
        delay(200);
        digitalWrite(led, LOW);
        delay(200);
       }
      
    }else // else for test only
    {
      digitalWrite(led, LOW);    // turn the LED off by making the voltage LOW
    }

}


Here is the finished item:



The camera enclosure doesn't have a great deal of space inside so the next challenge is to fit it all in!

The CPU is really under utilised but going forward, it will start to take on more responsibilities, such as fire the strobes and monitoring pressure.  Watch this space.