I am looking for a small simple switch. But it has certain restrictions because I want to use it for salt water aquarium and copper exposure is lethal to some fauna, as well as some plastics.

Looking around the internet i found floating switches, optical switches, rod inducting switches, a few diy projects switches i.e. a Sonar switch- very promising just with salt.. well salt accumulates in every place possible under the hood.

I might go with the sonar and a small arduino or attiny...

but I am wondering if it is possible to use a single wire to detect resistance change? or something clever like that. I only want to detect if the aquarium is about to overflow and shutdown pumps in case off emergency- so minimum copper exposure wont kill anything but flooding my wooden floor.. well the wife will kill me..

My aquarium (and most other Marine hobbyists will have these spec ranges)(only advanced people will go over or under these for other specific reasons)

  • Temp 22~26 Celsius (ME: 24oC)
  • Salinity 1.022 ~ 1.026 (ME: 1.026) (Specific Gravity)

But I would like to assume this works on Clean water too( as in Reverse Osmosis with no minerals or salt) The distance would be max 1 cm apart- no need to measure the entire tank.


2 Answers 2


There are clever techniques for sensing water with a microcontroller. I'm doing that with one of my projects right now. Sensing even distilled water is actually pretty easy with the right algorithm.

However, since this is just a basic failsafe switch, simple and dumb is better. I would use a float and a mechanical switch. Have the switch be normally closed and run all the power thru it. When the tank gets above the fault level, the switch opens and shuts off everything. Keep it simple.

If you really want to know about electronic water detection, I can get into more details, but it doesn't sound appropriate here. Something as simple as what Oli described can work, but has its problems. With a micro you can get more sophisticated to get around problem like noise and net DC current.

More on electronic water detection:

There are several problems with electronic water detection using resistance. This method can be made to work nicely and reliably with little effort, but you have to be aware of the issues and know that you have dealt with them. Issues include:

  1. Water bridge. This is usually due to dirt buildup on the surface of whatever is holding the two conductors and then that getting wet and retaining enough water to make a connection. Sometimes just dirt and humidity can do it. In extreme cases with ridiculously close sensors, you can even have capillary action forming a outright water bridge between the two sensors.

    The best way to deal with this is to make the surface creapage distance between the closest points of the two conductors long and of hydrophobic material. Keep in mind though that a dirt coating defeats a material's hydrophobic properties.

  2. Electrolysis. This doesn't necessarily hurt the sensor but but can cause problems with stuff that may be in the water. It also greatly accellerates electrode corrosion, which does hurt the sensor.

  3. Corrosion. Should be obvious, and salt water is particularly bad. Again, a net DC current can cause electrolysis, which can cause serious corrosion much quicker than otherwise.

  4. Battery effects. Even little asymmetries of the sensors can result in a average DC open circuit voltage between the sensors. The voltage will be low and the impedance high, but often these sensor circuits are designed to use µA and MΩ, so this can confuse a naively designed algorithm.

  5. Electrical noise. With MΩ impedances, all kinds of noise from nearby electrical devices can be picked up. Most of this can be dealt with by aggressive low pass filtering and realizing the noise will mostly be common mode. This is not hard to do, but simple knee jerk dumb approaches can have problems due to this.

One of my current projects includes sensing whether a hand held unit is immersed in water or not. This has to work with clean or dirty water, although it is not intended for salt water. The electrodes are about 1 inch apart and plated with something corrosion resistant. I don't know what exactly that is. These are the same electrodes used successfully on previous products and I have nothing to do with their design.

Each electrode can be either driven by a processor pin or its voltage read by the processor A/D while being passively pulled down with a appropriate resistance like 1 MΩ. I don't want to get into too much detail of this product, but basically the strategy is to use a 4-phase measurement. The voltage on each pin is measured with the other pin driven both high and low, with low pass filtering and sufficient settling time. To get a single metric of water detection, I take the two high measurements minus the two low measurements. Note that this cancels out any common mode signal and any steady differential mode signal.

In this case I have the advantage that the product is hand held and battery operated, so there is no net path to ground or elsewhere outside the unit. You can make this true in your case, which would be a good idea, if the microcontroller is running from a separate isolated supply. Basic safety should dictate this anyway.

In the product I mentioned, we consider water to be present when the resistance between the two electrodes is 3 MΩ or less. You should be able to use a significantly lower threshold since salt water is many times more conductive than the clean water we have to assume is our worst case.

  • 1
    \$\begingroup\$ You should really create a blog and share your knowledge. I would check it out for updates every 100usec :) \$\endgroup\$ Commented Jun 15, 2012 at 11:31
  • \$\begingroup\$ Thanks. I really do not want to use a float as it looks ugly in a nice tank.. I am looking for as discrete as possible. Thats why i spent more money to move everything to the sump. But I need a failsafe incase my overflow fails.. What problem could i expect using Oli's method? \$\endgroup\$
    – Piotr Kula
    Commented Jun 15, 2012 at 11:37
  • 1
    \$\begingroup\$ [service message] @ppumkin - you use "@" to notify a user, but it only works for users which have commented here and the answerer. \$\endgroup\$
    – stevenvh
    Commented Jun 15, 2012 at 11:40
  • \$\begingroup\$ From another source I hear that Stainless Steel is reef safe.. if completely submerge or completely dry. If i use some SS wire as the switch would it cause any issues that I would be un aware of? that you might know of? \$\endgroup\$
    – Piotr Kula
    Commented Jun 15, 2012 at 15:21
  • \$\begingroup\$ I am not a chemist, so don't know what conditions stainless steel would be good for or not. I have heard of platinum or platinum coated electrodes and graphite electrodes used in specific harsh conditions, but again, I'm not sure of the chemistry behind that. \$\endgroup\$ Commented Jun 15, 2012 at 17:12

If i understand you correctly you just want to detect when the level of the (salt) water rises above a certain level.
If this is the case, why not just use two bare ended (aluminium? or some other non-toxic to fish/fauna metal) wires and detect (as you say) the resistance change in the same way a multimeter does.
Since salt water is very conductive, two wires spaced a couple of cm apart in a large volume will have a very low resistance. The Wiki page on resistvity gives a value for sea water of 0.2 ohm meters.
Resistance is (ohm meters) * (length / area) So for two wires with 1cm squared plates spaced 100mm apart in a tank of salt water, the resistance should be around:
0.2 * (0.1m / (0.01m * 0.01m)) = 200 ohms.
I say around as we don't know the exact salinity or temperature of your water. The Wiki figure is based on 35g/kg at 20 degrees C. In any case the exact value doesn't matter as long as there is some conductivity.

Basically, supply a small current limited voltage to one wire, attach the other wire to a common source configured N-Channel MOSFET with e.g. 1 Megaohm from gate to source, and the switch between drain and supply. When the water covers the (other) ends of the wires a small current will flow and turn the MOSFET on and operate the switch.
Depending on logic levels and size of switch you may need to use e.g. two FETs or a P-Channel FET.

  • \$\begingroup\$ Yea that sounds like what i had in mind.. I just did not know how to go about doing it. So even a small gap like 1mm should be fine to detect some conduction on like Arduinos pin supply voltage?Actually - Arudino would be overkill.. as the mosfet could trigger a relay and cut power right? \$\endgroup\$
    – Piotr Kula
    Commented Jun 15, 2012 at 10:52
  • \$\begingroup\$ Yes, Arduino would be overkill for this - a FET can trigger a relay, just make sure it has a low enough threshold voltage and a suitable current rating for your relay. If you need help with this part just let us know your planned supply voltage and your pump voltage/current rating. \$\endgroup\$
    – Oli Glaser
    Commented Jun 15, 2012 at 11:15
  • \$\begingroup\$ This simplistic approach can work, but it's really not much trouble to do it right. And no, a 1 mm gap is too small. You can even get capillary problems with a gap that small. \$\endgroup\$ Commented Jun 15, 2012 at 11:27
  • \$\begingroup\$ A resistance of 0.2 ohms would only apply to two conductive 150mm X 400mm plates at each side of the tank. For two wires the resistance would be much higher. \$\endgroup\$
    – MikeJ-UK
    Commented Jun 15, 2012 at 11:32
  • 1
    \$\begingroup\$ I'd use a gap of at least 1cm if going this route. I wouldn't say there is a right way to do this, resistivity is a common way to detect water levels. There are potential problems with a mechanical switch also. The Wiki page on Level Sensors has plenty of options if you are interested.. \$\endgroup\$
    – Oli Glaser
    Commented Jun 15, 2012 at 11:36

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.