# Sensing sea water in a box

#### ErnieM

Joined Apr 24, 2011
8,328
I've just talked myself into an interesting project. Concider a rectliniear box constructed of 1/8" thick polypropylene. My task is to sense the level of sea water inside the box, and while a continuous level would be preferred a simple high and low indication is acceptable.

As this box is located literally in the middle of a harbor inside a lighthouse where the only power typically available is 12VDC I'm not inclined to make many experiments on site. I eventually will get a piece of polypro to test against, but desire a complete sensor I can install once upon completion and sleep soundly that is will continue to work.

I would prefer to leave the box undisturbed and sense thru the box itself, perhaps using a projected capacitance sensor. Does anyone know if sea water is a good as a finger when a touch sensor is involved?

#### MrChips

Joined Oct 2, 2009
26,790
A number of solutions come to mind. Sea water is a reasonably good conductor.
You could try two parallel vertical wires and measure the conductivity to determine the water level. Platinum wires might be too expensive so you may try stainless steel. The problem is that the conductivity will vary especially with temperature.

The second solution is to use an ultrasonic range finder to measure the height to the surface of the water. Polaroid sold such sensors as used in their auto-focus cameras. They are also used in some digital measuring tapes.

Thirdly, you can use a float on an arm connected to a variable resistor or an optical position sensor to measure the angle of the arm.

Just some random thoughts.

#### John P

Joined Oct 14, 2008
1,983
I wonder if you could use a capacitive sensor working through the tank wall. Maybe stick two vertical metal strips against the wall, so the capacitance between them would increase as the level of water in the tank went up.

Or hang a plastic rod into the tank and measure its apparent weight. As more of the rod is immersed in water, its weight will appear to decrease.

#### atferrari

Joined Jan 6, 2004
4,648
Keep in mind how aggressive sea water is.

#### Duane P Wetick

Joined Apr 23, 2009
435
Today, the most reliable method of liquid level sensing is to use ultra-sonics.
No contact with the liquid is required and a conversion to litres or gallons is easy when using a micro-controller.

Cheers, DPW [ Everything has limitations...and I hate limitations.]

#### Externet

Joined Nov 29, 2005
1,879
Is the seawater in the box at the same level the tide is ?

Do you need to know the level while away from the box; like at a distance within the lighthouse, or the level will be checked at the box location ?

#### MrChips

Joined Oct 2, 2009
26,790
You can also tie a barometer to the end of a piece of string and let it down from the top of the lighthouse with a stepping motor. Use a stopwatch to time how long it takes. Then pull up the string and measure the length of the string. Oh, I almost forgot. Don't forget to tie a thermometer on as well to apply temperature compensation. An alcohol filled thermometer always works best.

#### strantor

Joined Oct 3, 2010
6,032
I like the idea of the plastic float mentioned. probably the simplest and cheapest. if you're not looking for an analog signal, you could mount the float to rod that moves up and down. the rod could have an arm on it that hits a high and low level limit switch; or any number of limit switches for that matter (0, 25% full, 50% full, 75%, etc)

#### ErnieM

Joined Apr 24, 2011
8,328
Keep in mind how aggressive sea water is.
Which is one reason I don't want to make any holes to make measurements. Also hole can leak. Electrodes will corrode inside the box where you can't see them, and even condensation will become conductive.

Ultrasonic is nice but still needs a hole, and is prone to corrosion, unless I can bang the signal up from the bottom of the tank thru the polypropylene. I worked on a system that made sure there isn't too much water inside the nuclear reactor on board the Seawolf and Virginia class subs (got on board the Virginia and the Texas too). Seems like too much R&D, and I think the tank is sitting on concrete.

The box is a holding tank for the toilet system. The toilet is adapted from a boat toilet. While it has a pump to flush itself, it only has a foot or two of head. As this toilet can be 10 feet above low water, a separate tank to hold water sea water for flushing was added. The toilet works flawlessly, but the holding tank needs to be replenished.

Filling the tank would seem to be simple, except for two problems: 1) if you run the fill pump for too long you can overflow the toilet, and 2) at dead low tide the pickup is out of the water for perhaps a half hour, and may burn out for lack of cooling water.

It was assumed by putting a timer on the fill pump both problems could be overcome. However this is a volunteer organization where you can't fire people, and some people working there are stupid (just a fact), and you just can't fix stupid. So when they turn the timer up to 30 minutes and walk away the room floods. So far they have not ruined any pumps but that is coming.

So I got involved. This is a simple system, 12V power (solar cells to battery bank, all beautiful USCG equipment we can tap into) input to control a 12V pump. I figure a low and high water sensor, one turns on and the other turns off the pump relay. Drop a micro controller in there and it is a snap to add timeouts for low tide not filling to over run too long. Make it have NO controls, just an ON button (it turns itself off) and maybe a bypass (keyed?) button to manually turn the pump on as long as you hold the button.

#### joeyd999

Joined Jun 6, 2011
4,476
You could use a series of magnetic reed switches, activated by a magnet attached to a float.

The nice thing about the switches is, first they're hermetically sealed so they won't corrode, and, second, if you use a strong enough magnet, they can be outside your 'box'.

#### strantor

Joined Oct 3, 2010
6,032
well if that's the case, and no holes allowed at all, that means nothing inside the tank. I would mount a capacitive sensor at the top of the tank. They can be adjusted. I use them to detect the presence of polymer pellets through a plexiglas wall. Getting them adjusted into the "butter zone" where they will trigger on the pellets, but not on the plexiglas is tricky, but would probably be a lot easier with water. these sensors are pretty expensive though. you could probably find some cheaper ones but can't guarantee if they would work.

#### THE_RB

Joined Feb 11, 2008
5,438
Can you use a strain gauge to measure the weight of the tank?

#### dataman19

Joined Dec 26, 2009
135
A float (like a toilet tank float) with a conductive rod, and a plastic rod.
Put two metal sleeves spaced about 1/2" (one on top of the other) with an insulator between them. Measure the plastic rod so that the metal rod is at the farthest distance when the float is at the bottom of the tank. Then space the plastic rod so that it breaks the conductive path when the float nears the top of the tank. No matter what the timer is set at - the power to the pump motor will turn off when the tank is full.
....
No room at the top of the tank. Use a pulley and weight the float so it floats just below the surface of the water in the tank. Connect the chain or wire to a cam that pushes a normally closed push button switch, wire the switch in-line with the pump power....
...
Both these versions are should I say it - "Idiot proof".
....
Dave
Phoenix, Arizona

#### ErnieM

Joined Apr 24, 2011
8,328
Both these versions are should I say it - "Idiot proof".
Dave: you haven't seen our idiots.

"A common mistake that people make when trying to design something completely foolproof is to underestimate the ingenuity of complete fools."

#### dataman19

Joined Dec 26, 2009
135
But over the years I have worked with "numerous Idiots" in numerous country's. Idiocy isn't national, it isn't racial, it isn't gender... heck it isn't breed specific....
Idiocy is prevalent ---- period.
When things are designed they should be designed for worse case (including worst idiot).
...
I once watched a Johnny Carson show where a gentleman that owned a step ladder company was a guest. He told a story about being sued by a midwest farmer (it was assumed to be a midwest farmer) for a defective ladder....
..
The individual had erected his farmer to paint his barn. He started work early in the morning. Around mid morning he took a short break. After the break he climbed the ladder. A few minutes later the ladder tipped over and he fell and broke his arm in the fall. The individual's lawyer argued that the ladder's instructions were defective and misleading.
..
In discovery it was found that the ladder was erected as specified in the inclosed owner's manual. But - the individual had erected the ladder with one leg propped upon a frozen manuer pile (frozen poop). It was early spring so when it warmed up the manuer pile softened. Essentiall he was sued because his company did not include the warning that one should not put the ladder up on a frozen manuer pile...
...
..
Back to your project... How about an over flow tube that just siphons the excess back out to the sea? Or down the drain... hey use them in the toilet (probably because in the early days the toilet industry got tired of complaints about over flowing toilet tanks.. just guessing).....
..
No electronics, and idiot proof...
..
Just a thought.
...
Dave

#### ErnieM

Joined Apr 24, 2011
8,328
Hey dataman. Actually there is an existing overflow, it's just not big enough to send it ALL back to the sea, and the bowl overflows after 10 minutes of filling the full tank. That's what my fool does, crank it up to half an hour of fill time and walk away.

I have something here that may work well. I made a projected capacitance sensor. Such a cap depends on the fringe field falling thru the area above the sensor, or here, inside the tank. A difference in dielectric constants can make a detectable change in sensor capacitance.

I made such a sensor. I just took a piece of copper single sided PCB material, and using suitable templates (a quarter and a bottle cap) made outlines for a .95" and 1.2" concentric circles. The copper area between these was removed (score to the line and worry it off with tweezers and a hot iron), leads attached and connected to a '555 (as my capacitance meter refused to "see" it).

Using the 555 in astable mode, R1=R2=20K gave me a nominal frequency of 700KHz. I overlaid this sensor with a piece of 1/4" polyethylene as my "tank" simulation. (While my tank is polypropylene, polyethylene has a similar dielectric constants.)

Using this setup gave the following results:

Rich (BB code):
Test Material              Frequency    % change
(none)                     700 KHz        - - -
My Hand                    600 KHz         14 %
Coke bottle (empty)        690 KHz         13 %
Coke bottle (sea water)    620 KHz         11 %
Noting the coke bottles do not present a planar surface to the sensor these are very encouraging results. I have a >10% change when the sample material is present, and this is easily detectable.

The next step would of course be to
A) get a planar surface to measure against.
B) experiment with various sensor shapes to optimize the detection area

While would so much prefer to do a continuous level sensor I don't think dealing with calibration issues would be worth my time, excepting of course if the system self-calibrates. This could be accomplished using a continuous sensor for relative level, combined with discrete point sensors. Then the point sensors would be used to drive the pump detection code, and also used to note the response of the continuous level sensor at those times; continuous level would then be a (fairly accurate) reading for an operator to use, but the system function is not compromised if they are off.

There are many dedicated chips out there that work as an astable to use a projected cap as a point sensor, but Microchip's AN1298 describes a method to use an A2D element as the entire driver. Basically, you charge the A2D holding cap to Vdd, discharge the sensor cap, then connect them in parallel by selecting an A2D channel common to the sensor. The charge on the hold cap will charge the sensor cap thus decreasing the voltage on it.

A PIC18F14K50 (have some on hand in a spare breadboard) has a hold cap of about 13.5pF. From my '555 measurements I'm getting a sensor capacitance from 34pF (free air) to 40pF (hand overlay). A D2A reading this combo should give a count reading of 291 (free air) or 258 (hand overlay), or about a 12% change. That's decent enough to use.

TI's "MSP430 Capacitive Single-Touch Sensor Design Guide" makes the best reference I have found to guide sizing the basic sensor pattern; basically it says larger pads with larger open rings sense the furthest away from the board.

#### strantor

Joined Oct 3, 2010
6,032
Outstanding. I've never seen anybody use a PCB to make a capacitive sensor. Was that your idea?

#### ErnieM

Joined Apr 24, 2011
8,328
Outstanding. I've never seen anybody use a PCB to make a capacitive sensor. Was that your idea?
Heck, everybody uses a PCB to make these sensors.

I've been looking at several sources. Your link to Siemans, while lacking any design data did nail down the phenomina that projective cap sensing is based on in the second figure showing the cap field lines that need to project up to the object detection zone. It also shows products with a large detection range (20mm = .78") are possible.

As far as the sensor pad layout, I found this gem from TI. Down in section 7 it gives tables showing the response for various sensor diameters and ground separations. TI, Microchip, Cypress to name a few all have demo boards for simple cap buttons.

Update: Started the day looking for shielding so the sensor only senses in one direction, and quickly discovered I had my sensor connected backwards: central pad to common, and the outer band as the cap. While this is very sensitive to far ranging sensing it is too sensitive and senses both sides.

When I correctly connected the cap the sensitivity range plummeted. So I was on a slightly wrong track but still very encouraged.

Also, with the cap correctly connected the backside can be shielded with a simple metal cover, either unconnected or connected.

Time to play with some simple brass plates to find a sweet spot for separation vs sensing distance.

#### John P

Joined Oct 14, 2008
1,983
To quote a piece of writing from the long-ago days of 09-19-2011, 04:59 PM:

I wonder if you could use a capacitive sensor working through the tank wall. Maybe stick two vertical metal strips against the wall, so the capacitance between them would increase as the level of water in the tank went up.
That way you could make an analog sensor out of it. Or just a concentric button ought to work.

#### ErnieM

Joined Apr 24, 2011
8,328
To quote a piece of writing from the long-ago days of 09-19-2011, 04:59 PM:

That way you could make an analog sensor out of it. Or just a concentric button ought to work.
Honestly your point was well taken, and will be looked at closely, as a continuous level sensor would be most helpful not only on the current problem, but there is also a waste tank down there full of sh*t, literally! It would be incredibly helpful if I could also measure that tank too so it could alert to call the pump out boat and tell people to stay out of the crapper until there's room for their sh*t too.

There's always a calibration issue, and once the system seems to work it would be most disastrous for it to miss a full tank. In a previous job I saw actual inspection photos of an intrusive (well gasketed) point level sensor used in a naval waste system. It was giving false readings, and the photos revealed this due to it being covered in a brownish dialectical material.