Comments wanted: Capacitive holding tank fluid sensor -> resistive input gauge

(Virgin post - please advise if I did not follow the rules in my posting :o )

In my boat I have a 240-33 Ohm resistive float sensor in the sewage tank that has clogged up and is hanging at 175 Ohm. There's no headroom above the tank to remove the sensor rod. Thus I've decided to ditch the sensor as I cannot be bothered with removing the sewage tank for yearly maintenance...

The readout is on a Wema holding tank gauge (HTG-BS-240-33 on this page: I cannot find any documentation of the insides of the gauge, but some measurements indicates that it is a simple "air core meter" I think. Boat DC Power (nominal 12V) is applied on the input. The sensor input seems to be the mid point between two coils that move the needle as I measure half the voltage from + to sensor input and the same from sensor input to earth. Grounding the input makes the needle go to full. I measured approx 120 mA going through the instrument when sensor was shorted to ground (rough measurement with cheapo clamp amperemeter). Based on the voltages measured when sensor was hooked up (175 Ohm in parallell with one of the coilds) I backcalculated the coil resistance to approx. 81 Ohms (impedance is more correct I guess, but should not be important when dealing with DC only?).

My Project plan is to make a 555-based oscillator with input capacitance from two aluminium/copper foil strips attached to the sewage tank based on these ideas and many other pages I've visited:

To minimize unwanted capacitance I will make a small board for the oscillator unit and place it as close to the metal strips/capacitor as possible. I guess a simple twisted pair should be sufficient to carry the frequency input? Distance is short from tank to gauge (0.5-1 m), but I have assumed that moving away as much of the Electronics from the tank as possible would be beneficial with regards to noise, so I plan to place the Arduino adjacent to the gauge. Maybe I should also think of putting the oscillator unit into a small grounded metal shield?

I am not sure if soldering would be possible with aluminium so I am thinking of ordering some copper tape that should allow soldering sensor wires. Suggestions/input on this are appreciated!

After everything is installed I plan to coat the metal strips with a transparent spray paint to avoid corrosion.

I will then measure the pulse length (averaging a large number of measurements) as described here:

The pulse length should be proportional to the capacitance for the below circuit (link), which again should be fairly proportional to the tank fluid level, ref. first link. The tank is actually a cube so complicated volume functions should not be needed. From the first link I assume to get capacitance values from the metal strips in the 10-100 pF range. Based on the below instructional on 555-oscillator unist I believe 1M and 10M should be a good choice for R1/R2 to produce 667Hz, 6.7kHz respectively, ref. 50kHz limit for pulseln() function as mentioned in second link.

For the output to the gauge I am planning to get a 8 channel SSR shield/extension board (the Controller will be a "Sunduino" UNO R3 I already have). The original gauge nominally 'outputs' 240 (empty) to 33 (full) Ohms. Since I don't know the circuitry (if any) inside the gauge I guess the safest thing would be to mimic the existing sensor which yields a resistance: The SSRs will be hooked up to output pins 0-7. I will then "short" each SSR channel with resistors 1, 2, 4 .... 128 (or as close as possible) and chain the SSR channels together to form a series of resistors that can be on (SSR open, current goes through resistor) or off (SSR closed, current bypasses resistor). I should then be able to use the portd-command and send a 0-255 number to mimic a resistance from 255-0 Ohm (reverse values since SSR channel on = resistor bypassed and vice versa) between the endpoints of SSR channel 0 and 7.

Not completely sure which wattage to choose for resistors: Boat DC voltage could be 15V worst case. If I send 254 to the SSR and keep only the 1 Ohm resistor in the resistor chain current would be approx 0.19 A (taking the other coil's 80 Ohm resistance into account) which would be 36 mW (R x I^2). I ignored the parallell 80 Ohm coil in this calculation since the values were so different. If I send 0 giving 256 Ohm resitor/coils combined resistance should be approx 140 Ohm, resulting in a total current of 110 mA @15V of which 26 mA goes through the 256 Ohm resistor chain, giving 88 mW power dissipation in the 128 Ohm resistor. Thus ordinary 1/4 W resistors should be OK?

I would also include some tactile switches for calibration of empty/full readings, tuning the gauge needle accurately and a reset button.

The structure of the sketch would be something like this I guess. Not sure if the below steps/bullets make any sense to other People than myself :slight_smile: :

  1. Initialize variables for gauge empty/full resistance values and tank empty/full pulse time measurements (rough, to be adjusted using adjustment/calibration subroutines)

  2. main loop polling on switches and performing subroutines 'measurement' and 'convert/write to sensor output' each xxx Seconds

  • calls gauge adjustment or calibration routine upon button pressed detection
  • mode LED to be lit when main loop running, off when entering adjustment/calibration modes
  1. subroutine for measurements;
  • perform xxxx (1024?) pulseIn() samples and average result
  1. subroutine for convert/write to sensor output;
  • divide pulseIn() result by difference sensor full/empty readings to get tank level ratio
  • multiply ratio by (tank empty - tank full resistance), add tank empty resistance
    (R=-(240-33)*ratio + 240 ideally, values to be substituted by the adjusted values for the gauge)
  • Write value (255-R) to pins 0-7 using portd command (is simpler inversion of binary values to save space possible?)
  1. subroutine for gauge adjustment;
  • set mode indicator (LED)
  • upon pressed button combination loop writing full/empty gauge Reading to sensor output, incrementing or decrementing value of global variable - delay of say 500 milliseconds per increment/decrement
    abort/set mode indicator/return to main loop upon pressed button combination
  1. subroutine for sensor calibration;
  • set mode indicator (LED)
  • upon pressed button combination run measurements subroutine and store new tank full/empty pulse times to global variable
    abort/set mode indicator/return to main loop upon pressed button combination

Interested in comments on feasibility, obvious mistakes/shortcomings, smart tricks etc. Anything really!

(Any unintended Capitalization of letters is attributed to Win 10 >:( )

After everything is installed I plan to coat the metal strips with a transparent spray paint to avoid corrosion.

Look up "conformal coatings"

I hope the tank is not metallic otherwise it won't work.

You will need copper to solder on. Craft shops have this for working with stained glass.

Good luck.

Tank is plastic. Forgot to mention..

Checked out conformal coatings. Added to BOM :slight_smile:

This is interesting and useful.

My experience is that nothing fails more frequently than the damn level sensor on the blackwater tank. And there is nothing guests like to do more than flush the head by holding the button for a long time.

Would aluminum plates be superior to the tape?

Not sure on aluminium/copper and what is best. There are several commercial systems. They seem to be using both, or a combination of aluminium strips with adhesive copper pads for attaching the sensor wires.

Looks like GTBecker abandoned the idea for a commercial solution. I thought his experiment with the rustoleum on the pvc pipe was interesting.

Not sure on aluminium/copper and what is best.

Electrically it makes no difference, it is just which is best to connect to. You can solder copper not aluminium. Aluminium is cheap but you have to make a connection to it. You can use conducting ink as a sort of glue or have a crimped connector.

I will go for copper. But aluminum foil seems ideal for home mockup and testing!

First mockup of sensor. Water with some NaCl to emulate seawater flush as in boat's waste tank. Capacity on my el-cheapo meter appeared to go smoothly from 10 to 60 pF while filling. Looks promising so far.

While waiting for ordered goods I was planning to make a simple oscillator circuit to start testing and coding. However I only have a few transistors and resistors in my drawer (a few diodes also if that helps). No capacitors... Guess I could do a makeshift Capacitor from aluminum foil if needed though. I have googled a lot but failed to come up with a working oscillator based on this, preferably one that is dominated by the capacitance measured, but any signal below 50 kHz would do really. Any suggestions?