IAN LANG ELECTRONICS

Funduino are, I think, a German  outfit and make Arduino clone boards plus all sorts of modules to slap on to them. This particular item on the right is a module they do amongst others and what it does is senses the presence of water.

 

It does it by those long conductive bars you see running down it, plus some resistors and a tiny little transistor which I can't even see to identify and an LED to show that power is on to the module. You can see there's only three pins, +5V, GND and a signal wire. It comes with a right-angled header on it and that's not really any good on its own and so the best idea is to stick some female - male Duponts on it to make a lead.

 

Let's see it working in a little video:

Go Back

The Funduino Water Sensor

watersensor

Now as you might have spotted in that video above, lapping (ie water splashing) may be a problem here. We are going to have to come up with a creative way to overcome that but for now this is the schematic and code for that test rig above.

watersensorschem

The observant amongst you will notice that I've indulged in a naughty practice here in that I'm running an LED without a forward resistor. The LED in question is a 5mm one, and contrary to what you've always been taught you can get away with running such at about 3V with no resistor, though the lifespan will be shortened a tad. Here's some code:

 

// Using the Funduino water sensor with Arduino

// Ian Lang Electronics August 2016 - Ian

// Test version - shove a 5mm LED between A0 and GND; don't need a resistor. It's input and so only little current.

// You will need a bit of kitchen towel or a dry cloth though. This gets a bit wet. Don't get it near your keyboard.

// Dab your thumb in the water pot and shove it on the sensor as well. Wonder if we can make a sweatometer?? :)

 

 

#define itsWet  2// signal to pin wherever, in this case pin 2

 

 

void setup()

{

   pinMode(itsWet, INPUT);// sets signal pin to receive input

}

 

void loop()

{

 // Sensor immersed and not immersed in water. But not at the same time. It's not Schroedinger's sensor.

 // When it's dry, the signal is digital zero. When it's wet, the signal is digital one and so:

 if (digitalRead(itsWet)==HIGH){

   analogWrite(A0,200);}

   else{analogWrite(A0,0);}

}

 

This one's got a lot of REM statements up at the top, the Arduino will ignore them and you can too if you like. Ignoring all REM statements, the actual sketch begins with this line:

 

#define itsWet  2

 

#define means assign a value to a named variable. In this case the named variable is isWet and the value is 2. This is the pin number on the Arduino to which the signal from the sensor will be attached.

 

Next we go into the setup, and make sure that pin 2 is set for receiving input:

 

  pinMode(itsWet, INPUT);

 

and in the loop we have only one thing, which is determine if the signal is 0, in which case no water is detected, or 1, in which case water is detected. If water is detected then we switch the LED on, if not then we switch the LED off. So:

 

if (digitalRead(itsWet)==HIGH){            in plain English, if the signal is 1

 

The following  line shouldn't work but I thought I'd try it and it does. To a point.

 

analogWrite(A0,200);}   or in plain English switch LED on low.

 

The next line is what to do if the above conditional is not true (ie the signal is 0):

 

else{analogWrite(A0,0);} and again in plain English that's switch the LED off.

 

 

All the above works but it's a bit fauve; it does not account for lapping of water and we need an audible alarm system if it's going to work as a flood or leak warning device. Moreover we need to be able to multitask this device to look for fill-level or flood/leak conditions. For the former we need to account for lapping and for the latter we most certainly don't and so we need a way to cross it over. Best get to work on it then.

 

So, we'll keep the LED in place as a visual indicator but we'll make it so that it flashes on briefly and then off again when the device is switched on as well as coming on when water is present. But we'll move it over to some digital pins and put a proper forward resistor on it. The first thing we need to do is sort out an alarm and for that we need to decide on a voltage to work the thing. As this is going to be in wet conditions the safest thing is to use a low one, between nine and twelve volts (later on we'll need an IP66 case to enclose it but that's not a worry now). We could use a horrible loud siren but we don't know if anybody will be standing close to it when it goes off, and so something not so ear-splitting may be called for here.

 

Experimenting with this thing hooked into the analogue inputs at A5 reveals that it can measure water depth but it doesn't do it terribly well. Just breaking the surface tension of the water gives a reading of around 330 and immersing at the top of the bars gives us about 690. Halfway up the bars gives about 630. All of this is assuming the bits not immersed in water are bone dry, if not then the readings can be skewed. Not a very accurate device then, but good enough for what we want to do with it.

 

Let's turn our attention to the construction of an audible alarm system first. If we attach a 100 ohm resistor and a loudspeaker to a pin, we can make that pin make an audible tone, but it won't be terribly loud. We need to amplify the tone, and one way we can do that is with a Darlington transistor.

 

darlington pair

The Darlington transistor is also known as a Darlington pair because it is in fact two transistors joined together as you see on the left. The collectors are joined to the same supply but the feed to base is input at the first one. This allows the first one to conduct and the emitter of the first one feeds the base of the second. This causes a very big gain; in some cases in the order of 10,000 or so. The second transistor needs to be pretty meaty.

You can make a Darlington transistor using a 2N3904 as the first and a TIP31 as the second but by the time you've paid for both and the solder you'll need it's just as cheap to buy a ready-made one and the one I'm going to use is a BDX33C which is very common and can be bought anywhere. The pin-out is as below:

bdx33

As you see it comes in a TO 220 package and the mounting base can be put on a heat sink. That's because in some applications this thing gets hot. It can handle a collector current of 10 A. It can do 70W and get to a temperature of 150 centigrade before it starts to fail. We are not going anywhere near that parameter. We're feeding 9V to both the amplifier and the Arduino and we're taking a few milliamps at the base. It'll still be horribly loud though.

 

Over the page we hook this in to the Arduino with a loudspeaker (and move the LED to a better place whilst we are at it).

More >