"Blackwater" Tank Level sensor - Rasp pi

I have a project to sense the level of liquid is a waste water tank on a boat. The nature of the contents…it must be non- fullcontact, I cannot penetrate the tank - the sensor must see through the tank wall.
detection at 2 levels is desirable, 1/2 full and 7/8 full.
Id like to connect and run this with raspberry pi.
Id like to also have a visible LED in the toilet area to indicate levels.

What is needed for parts please? Voltage split to get from 5V to 3.3V, and (connection)wiring diagram.

What is the requirement on the Rpi spec? I’m planning a 4 as the centre of the boat to run chartplotting functions.

Thanks in advance


Hi Col,

Welcome to the forums :slight_smile:

That non-contact liquid level switch is certainly a good option.

Raspberry Pis use 3.3v logic, so you’ll need to drop the 5v from that switch down to 3.3v. You should be able to get away with a simple resistor voltage divider.

Checkout this handy resistor calculator:


Your supply voltage is 5v, your desired output voltage is 3.3V - choose any value for R1 and it’ll tell you what R2 should be. Just keep in mind you want a relatively high impedance so that this isn’t sapping too much current from your supply - classic ohms law.

Mind you, this doesn’t offer much in the way of protection if you have a poor connection, so you may prefer to use a level shifter:

As for resistor values, you’re limited to what’s available off the shelf unless you use a pot. The resistor (and capacitor, inductor etc) values are always from the E-Series of Preferred values:

I’d suggest a 2k Ohm and 3.9k Ohm resistors as these are part of the E48 series, which is readily available and will nominally output 3.305v - definitely within spec for the Pi.

As for the pinout you’ll be able to power this switch from the 5v rail from the GPIO on your Pi, and then read the value (via the voltage divider) from pretty much any GPIO pin of your choosing.

Checkout https://pinout.xyz and chapter 2 of our Pi for Beginners tutorial:

1 Like

Hi Oliver,

This sounds great and I’ve started working through the you-tube tutorials.

I prefer your suggested approach of the logic level converter as better than the resistor based voltage splitter.

I’ve put together the list below, but will also need a power supply. Do you have available DC 12V to 5V? (I’d prefer to order all at the one time)

  • Raspberry pi 4B 4GB SKU: CE06425
  • 16GB micro SD with NOOBS SKU: CE00279
  • Micro HDMI to HDMI cable 1m SKU: CE06431
  • Raspberry pi case model 4 SKU: CE06432
  • Media centre wireless keyboard SKU: CE05824
  • Logic level converter bi-directional SKU: BOB-12009
  • 2 of Non-contact liquid level switch SKU: FIT0212 THIS SWITCH is zero calibration at power on, so if tank is already half full, this would not work. Is there a better option?

Do I have it all or do I need Arduino?

The Raspberry Pi will also be working as a chart plotter, and will take in data from using openCPN or similar, as well as wind and depth data from existing instruments by wifi input hence the spec, (or is that too high?).

Initially I’ll use an HDMI screen in the cabin, later to a second, hi visibility screen in the cockpit.

Thanks in advance


just some reading…

Thanks Brian,
I’d read through that, but understood the sensor required a tank penetration. I’m sensing the level in a Blackwater tank. Essentially raw sewage, so need a solution that avoids penetrating or potentially compromising the integrity of the tank.
Happy if I misread the water tank project.

From phone

1 Like

the blackwater term confused me…just that there is so much electronic jargon these days…

I dare say that sounds like a good idea :sweat_smile: depending on the material of the container and its thickness you should be able to use either that non-contact switch that you’ve linked first or this other capacitive level sensor I’ve linked below. Either way they should be quite easy to use, DFRobot has a good tutorial on their wiki about it.


Thanks, that looks like a useful sensor for my application. The tank is polyethylene and I estimate 5mm thick, so all good there. I read the dfrobot page, but its not clear on the power on status, so I’m hoping that someone can assist me on this, perhaps experience with it?

Assuming all set up and adjusted. If the tank is filled to the sensor level, say half full, triggering the capacitive sensor and then the power was disconnected. Next time the system is powered on, which may be a week later, would the sensor re-zero itself and show empty, or would it retain the half full status?

Appreciate any input, thanks!

1 Like

Hi Colin,

Personally for your application, I’d recommend the first link that you’ve suggested, it should be much simpler to set up as long as you don’t strictly require high precision measurement. You just throw one in at each of the heights that you need and monitor their output by taking readings through the GPIO in a python script or similar.

(Please note that since the logic on these is at 5V you’ll need a logic converter to safely use it with the Pi, should be able to use one of these for a few sensors at the same time as Oliver said)

1 Like

But that simple switch RE zeros when power comes on. So if tank level is already above it would show empty.
It’s not an always on situation. If
It could be a couple of weeks between the system being powered up…

From phone

1 Like

Bryce said…You’ll want to use the Uno in this case, and then communicate back to the Pi via serial using a custom script in order to integrate it into your project which can just be ‘listening’ via Serial and then output the appropriate data to a display (at least in my experience that would be the simplest way to set this up) that being said, if you’d prefer just to use the Pi, you can instead use an ADC (analogue to digital converter) which can take the analogue outputs and then convert them to the appropriate digital signals for you Pi (likely using a protocol such as I2C) I’d start by just getting your system working with the Arduino first, then adding a Pi into the mix afterwards once you’ve debugged any issues that occur through the setup. All the best with your project! Please let us know on the forum if you have any further questions.

This capacitive sensor is not analogue (insofaras I can Tell)
The light is on, or off. Theres a voltage output… or not. High or low

Maybe I’m missing something

Testing the output voltage from the sensor, the voltage is 3.3V.
So looks like the logic level not note needed?

Hey Colin,

That’s correct, the high and low are 2.2V and 3.3V which should be enough to trigger the high and low on a digital read as opposed to an analogue input although both are suitable options. You can always try changing the sensitivity on the sensor to see whether you can make it trip correctly to match the water level using a digital read, although it will require some experimentation to get it working correctly. I’d suggest throwing it together and then seeing whether the issues arise first rather than trying to troubleshoot for issues using it before they occur. Have a great day!

OK, so Arduino and logic level converter not required.

Its now a matter of configuring the GPIO pins. That should be OK.

Is there software available that would let me have a screen to graphically display the output. Doesnt need to be too flash, just some sort of guage, at its simplest form, even a representation of an LED on screen would do the job.

If 1/2 tank level = LOW and 3/4 tank level = low then display green light
IF 1/2 tank level = HIGH and 3/4 tank level = low then display amber light
if 1/2 tank light = high and 3/4 tank level = high then display RED

Hi Colin,

The quick and easiest method to set that up would be to write a little script in python that will provide an output value based on the digital inputs. I’ll link through a workshop for you to get started with it, should be able to put that together based on the content in chapter two.

If you have any further questions please let us know, please be sure to send a photo of the completed project, I’m curious to see how this turns out! :grin:

Hi guys.
Been keeping an eye on this thread with a future interest in mind.
Has anyone solved the problem re the sensor resetting every time at power up? As Colin says it could be days or weeks between uses and hence power on and if the tank has liquid in it those sensors below this level will show empty all the time. Or has someone found an alternative non contact sensor to do this job.
Just interested as this problem seems to have been bypassed.
Cheers Bob

1 Like

Thanks Bryce. Ive gone through a lot of those. I’m finding, they are all about using a button, switch to turn on an LED. I’m going to call this outputting.

What I need is inputting. Two sensors, 3 conditions.

Condition 1 = No voltage from both sensors voltage comes through GPIOs Displays on screen as green

Condition 2 = No voltage from high level sensor, +ve voltage from low sensor. Displays on screen as amber

Condition 3 = +ve voltage from both sensors. Displays on screen as red.

Really I should be able to display this using Node red dashboard as a gauge. That would be perfect. I’m sure it can be done, but there’s not enough useable detail in online tutorials demonstrations.

I’m at the project time-point of installing now. All I can do is get the sensors to output to an LED. I’ll have to install with their own power supply and without any use of RPi. It’ll just be a pair of LEDs that I can see in the head that tells me tank status.

You’d see on the forum this has been up for a couple of weeks.

I was recommended to get Arduino and 2 level converters via the help desk. Theyre not needed. That’s disappointing.

I am not at the point that I would recommend this and use an installation for other clients.



1 Like

Hi Robert,
I’ve given up on this as a Raspberry Pi problem. I’m too far removed from the R-PI jargon to be able to make use of the various you-tube info availablle. Node-red dashboard looks good, but too big of a jump for me just yet with the time I have available to get something working.


The sensors work and will sense. They’re on if there’s stuff there and off if not. Its easy for me to supply power to the sensors in the head on the boat. They can then trigger an extension LED that can be mounted anywhere. I’ll be mounting two red LEDs in the head. If one is on I’m at that level and if both on, its time to visit pump-out.

I miss out on the nicety of having an on-screen display, but its simple and will work just fine.


Hi Colin.
Simple but effective. It is true that you can be really bogged down with too much complexity. Pretty, but on a boat where panel space is usually at a premium not warranted.
Cheers Bob


KISS - never fails.

1 Like