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:
- 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.
- 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.
- 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.
- 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.
- 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.