# "Blackwater" Tank Level sensor - Rasp pi

**URL:** <https://forum.core-electronics.com.au/t/blackwater-tank-level-sensor-rasp-pi/9303>\
**Category:** Raspberry Pi\
**Created:** [1 February 2021 00:12 UTC](https://forum.core-electronics.com.au/t/blackwater-tank-level-sensor-rasp-pi/9303 "2021-02-01T00:12:53Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![Colin153015](https://avatars.discourse-cdn.com/v4/letter/c/5daacb/32.png) [@Colin153015](https://forum.core-electronics.com.au/u/Colin153015)\
**Post date:** [1 February 2021 00:12 UTC](https://forum.core-electronics.com.au/t/blackwater-tank-level-sensor-rasp-pi/9303/1 "2021-02-01T00:12:53Z")

</div>

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.

- [Non-contact Liquid Level Switch Australia](https://core-electronics.com.au/non-contact-liquid-level-switch.html)

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

Col

---

<div class="post-metadata">

**Author:** ![Oliver](https://yyz2.discourse-cdn.com/flex028/user_avatar/forum.core-electronics.com.au/oliver/32/3315_2.png) [@Oliver](https://forum.core-electronics.com.au/u/Oliver)\
**Post date:** [1 February 2021 03:42 UTC](https://forum.core-electronics.com.au/t/blackwater-tank-level-sensor-rasp-pi/9303/2 "2021-02-01T03:42:26Z")

</div>

Hi Col,

Welcome to the forums 🙂

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:

[https://ohmslawcalculator.com/voltage-divider-calculator](https://ohmslawcalculator.com/voltage-divider-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:

> **[Logic Level Converter Bi-Directional](https://core-electronics.com.au/logic-level-converter-bi-directional.html)**
>
> Have your Raspberry Pi and Arduino talking to each other in no time. This device will let you safely communicate between two devices that use different logic levels (3.3V and 5V for example).

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:

> **[E series of preferred numbers](https://en.wikipedia.org/wiki/E_series_of_preferred_numbers)**
>
> The E series is a system of preferred numbers (also called preferred values) derived for use in electronic components. It consists of the E3, E6, E12, E24, E48, E96 and E192 series, where the number after the 'E' designates the quantity of value "steps" in each series. Although it is theoretically possible to produce components of any value, in practice the need for inventory simplification has led the industry to settle on the E series for resistors, capacitors, inductors, and zener diodes.

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](https://pinout.xyz) and chapter 2 of our Pi for Beginners tutorial:

> **[Raspberry Pi Workshop for Beginners - Tutorial](https://core-electronics.com.au/tutorials/raspberry-pi-workshop-for-beginners.html#ch2)**
>
> Welcome to the Raspberry Pi Workshop for Beginners! Here you'll be able to follow along with our series of bite-sized videos that cover everything you'll need to know to get started with your Raspberry Pi, and start making awesome projects. My name...

---

<div class="post-metadata">

**Author:** ![Colin153015](https://avatars.discourse-cdn.com/v4/letter/c/5daacb/32.png) [@Colin153015](https://forum.core-electronics.com.au/u/Colin153015)\
**Post date:** [2 February 2021 08:11 UTC](https://forum.core-electronics.com.au/t/blackwater-tank-level-sensor-rasp-pi/9303/3 "2021-02-02T08:11:02Z")

</div>

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

Colin

---

<div class="post-metadata">

**Author:** ![brian86770](https://avatars.discourse-cdn.com/v4/letter/b/c5a1d2/32.png) [@brian86770](https://forum.core-electronics.com.au/u/brian86770)\
**Post date:** [2 February 2021 08:32 UTC](https://forum.core-electronics.com.au/t/blackwater-tank-level-sensor-rasp-pi/9303/4 "2021-02-02T08:32:32Z")

</div>

> [@Project by Denver42165; Water Tank Level Sensor](https://forum.core-electronics.com.au/t/project-by-denver42165-water-tank-level-sensor/1896):
>
> Denver42165 just shared a new project: ["Water Tank Level Sensor"](http://core-electronics.com.au/projects/water-tank-level-sensor) Imagine getting home from work, its winter, its cold. You have a shower to warm up and half way through your shower… your water stops. You wrap a towel around yourself, remove the shampoo from your eyes and go out into the cold to swap the tanks as the water tank you were using had run dry. This was a common occurrence in my house… but not anymore. Now I can keep visually see the level of water in my water tanks on my iP…

> [@Ultrasonic Water Tank Level Monitor](https://forum.core-electronics.com.au/t/ultrasonic-water-tank-level-monitor/5261/2):
>
> So if anyone is interested… I have spent all morning on this - remember this is my first python program too ! I found such inconsistancies in reading - most likely the second read would be well out there - sometimes twice as big as it should be - once 10 times! Other times, it could be a lot lot smaller than it should be… So it made me think - how to remove the outliers… If I could ignore the items that occurred at each extreme, and then looked at the average of ‘good’ data - would I then have…

> [@Water tank level monitoring + Node Red](https://forum.core-electronics.com.au/t/water-tank-level-monitoring-node-red/5693/2):
>
> Well after a bit of thinking I have the node-red side more-or-less sorted, at least as a proof of concept anyway. I have used sliders to represent my GPIO’s being Hi or LOW and had to use a JOIN node to pull my 5 GPIOs together such that I could manipulate the data in a function node. A few ‘if’ statements later and I have chart representation of my theoretical water tank. Could this be more efficient, or is there a better way? [{"id":"762b3609.fe53a8","type":"join","z":"6d91a674.1b8e38","nam…

> [@Water tank level monitoring + Node Red](https://forum.core-electronics.com.au/t/water-tank-level-monitoring-node-red/5693/6):
>
> Thanks guys, Noting the possible electrolysis issues, Im thinking of reverting back to measuring the depth of my water tank(s) with an ultrasonic sensor (with LoPy4 via TTN & NodeRed). I would want the LoPy4 to wake once from Deepsleep every 24hrs and the battery to last for a couple of months (or more). A few questions please: What regulator would you suggest to power the sensor (SEN0208)? Which battery would you suggest to achieve my goal of a couple of months? If the 5V power drain woul…

just some reading…

---

<div class="post-metadata">

**Author:** ![Colin153015](https://avatars.discourse-cdn.com/v4/letter/c/5daacb/32.png) [@Colin153015](https://forum.core-electronics.com.au/u/Colin153015)\
**Post date:** [2 February 2021 09:52 UTC](https://forum.core-electronics.com.au/t/blackwater-tank-level-sensor-rasp-pi/9303/5 "2021-02-02T09:52:13Z")

</div>

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.  
Cheers  
Col

From phone

---

<div class="post-metadata">

**Author:** ![brian86770](https://avatars.discourse-cdn.com/v4/letter/b/c5a1d2/32.png) [@brian86770](https://forum.core-electronics.com.au/u/brian86770)\
**Post date:** [2 February 2021 21:48 UTC](https://forum.core-electronics.com.au/t/blackwater-tank-level-sensor-rasp-pi/9303/6 "2021-02-02T21:48:48Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![Bryce](https://yyz2.discourse-cdn.com/flex028/user_avatar/forum.core-electronics.com.au/bryce/32/3631_2.png) [@Bryce](https://forum.core-electronics.com.au/u/Bryce)\
**Post date:** [3 February 2021 01:16 UTC](https://forum.core-electronics.com.au/t/blackwater-tank-level-sensor-rasp-pi/9303/7 "2021-02-03T01:16:25Z")

</div>

> [@Colin153015](#):
>
> Essentially raw sewage, so need a solution that avoids penetrating or potentially compromising the integrity of the tank.

I dare say that sounds like a good idea 😅 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.

> **[Non-contact Capacitive Liquid Level Sensor Arduino Wiki - DFRobot](https://wiki.dfrobot.com/Non_Contact_Capacitive_Liquid_Level_Sensor_SKU_SEN0368)**
>
> Wiki: This is a non-contact liquid level sensor with status indicator and adjustable sensitivity function. It can be used in liquid detection of non-metallic container or pipe(outer diameter\>11MM), suitable for all types of detection of curved or...

> **[Non-contact Capacitive Liquid Level Sensor](https://core-electronics.com.au/non-contact-capacitive-liquid-level-sensor.html)**
>
> This is a non-contact liquid level sensor with status indicator and adjustable sensitivity. It can be used in liquid detection of non-metallic container or pipe(outer...

---

<div class="post-metadata">

**Author:** ![Colin153015](https://avatars.discourse-cdn.com/v4/letter/c/5daacb/32.png) [@Colin153015](https://forum.core-electronics.com.au/u/Colin153015)\
**Post date:** [3 February 2021 07:47 UTC](https://forum.core-electronics.com.au/t/blackwater-tank-level-sensor-rasp-pi/9303/8 "2021-02-03T07:47:51Z")

</div>

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!

---

<div class="post-metadata">

**Author:** ![Bryce](https://yyz2.discourse-cdn.com/flex028/user_avatar/forum.core-electronics.com.au/bryce/32/3631_2.png) [@Bryce](https://forum.core-electronics.com.au/u/Bryce)\
**Post date:** [4 February 2021 03:02 UTC](https://forum.core-electronics.com.au/t/blackwater-tank-level-sensor-rasp-pi/9303/9 "2021-02-04T03:02:47Z")

</div>

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)

> **[Logic Level Converter Bi-Directional](https://core-electronics.com.au/logic-level-converter-bi-directional.html)**
>
> Have your Raspberry Pi and Arduino talking to each other in no time. This device will let you safely communicate between two devices that use different logic levels (3.3V and 5V for example).

> **[Non-contact Liquid Level Switch](https://core-electronics.com.au/non-contact-liquid-level-switch.html)**
>
> This non-contact liquid level switch can be triggered when the liquid level fall below the sensor attached to the outside surface of a non-metal container. Unlike traditional liquid level sensors, it does not need to be immersed into liquid.

---

<div class="post-metadata">

**Author:** ![Colin153015](https://avatars.discourse-cdn.com/v4/letter/c/5daacb/32.png) [@Colin153015](https://forum.core-electronics.com.au/u/Colin153015)\
**Post date:** [4 February 2021 04:17 UTC](https://forum.core-electronics.com.au/t/blackwater-tank-level-sensor-rasp-pi/9303/10 "2021-02-04T04:17:21Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![Colin153015](https://avatars.discourse-cdn.com/v4/letter/c/5daacb/32.png) [@Colin153015](https://forum.core-electronics.com.au/u/Colin153015)\
**Post date:** [9 March 2021 05:14 UTC](https://forum.core-electronics.com.au/t/blackwater-tank-level-sensor-rasp-pi/9303/11 "2021-03-09T05:14:03Z")

</div>

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.

BUT\>\>\>\>\>\>\>\>\>\>\>\>\>\>\>\>  
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

---

<div class="post-metadata">

**Author:** ![Colin153015](https://avatars.discourse-cdn.com/v4/letter/c/5daacb/32.png) [@Colin153015](https://forum.core-electronics.com.au/u/Colin153015)\
**Post date:** [9 March 2021 05:41 UTC](https://forum.core-electronics.com.au/t/blackwater-tank-level-sensor-rasp-pi/9303/12 "2021-03-09T05:41:13Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![Bryce](https://yyz2.discourse-cdn.com/flex028/user_avatar/forum.core-electronics.com.au/bryce/32/3631_2.png) [@Bryce](https://forum.core-electronics.com.au/u/Bryce)\
**Post date:** [9 March 2021 06:07 UTC](https://forum.core-electronics.com.au/t/blackwater-tank-level-sensor-rasp-pi/9303/13 "2021-03-09T06:07:49Z")

</div>

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!

---

<div class="post-metadata">

**Author:** ![Colin153015](https://avatars.discourse-cdn.com/v4/letter/c/5daacb/32.png) [@Colin153015](https://forum.core-electronics.com.au/u/Colin153015)\
**Post date:** [9 March 2021 06:31 UTC](https://forum.core-electronics.com.au/t/blackwater-tank-level-sensor-rasp-pi/9303/14 "2021-03-09T06:31:00Z")

</div>

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.

eg  
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

---

<div class="post-metadata">

**Author:** ![Bryce](https://yyz2.discourse-cdn.com/flex028/user_avatar/forum.core-electronics.com.au/bryce/32/3631_2.png) [@Bryce](https://forum.core-electronics.com.au/u/Bryce)\
**Post date:** [16 March 2021 02:31 UTC](https://forum.core-electronics.com.au/t/blackwater-tank-level-sensor-rasp-pi/9303/15 "2021-03-16T02:31:34Z")

</div>

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.

> **[Raspberry Pi Workshop for Beginners - Tutorial](https://core-electronics.com.au/tutorials/raspberry-pi/raspberry-pi-workshop-for-beginners.html)**
>
> Welcome to the Raspberry Pi Workshop for Beginners! Here you'll be able to follow along with our series of bite-sized videos that cover everything you'll need to know to get started with your Raspberry Pi, and start making awesome projects. My name...

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! 😁

---

<div class="post-metadata">

**Author:** ![Robert93820](https://avatars.discourse-cdn.com/v4/letter/r/ac91a4/32.png) [@Robert93820](https://forum.core-electronics.com.au/u/Robert93820)\
**Post date:** [16 March 2021 04:18 UTC](https://forum.core-electronics.com.au/t/blackwater-tank-level-sensor-rasp-pi/9303/16 "2021-03-16T04:18:19Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![Colin153015](https://avatars.discourse-cdn.com/v4/letter/c/5daacb/32.png) [@Colin153015](https://forum.core-electronics.com.au/u/Colin153015)\
**Post date:** [16 March 2021 04:18 UTC](https://forum.core-electronics.com.au/t/blackwater-tank-level-sensor-rasp-pi/9303/17 "2021-03-16T04:18:42Z")

</div>

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.

Thanks

Colin

---

<div class="post-metadata">

**Author:** ![Colin153015](https://avatars.discourse-cdn.com/v4/letter/c/5daacb/32.png) [@Colin153015](https://forum.core-electronics.com.au/u/Colin153015)\
**Post date:** [16 March 2021 04:37 UTC](https://forum.core-electronics.com.au/t/blackwater-tank-level-sensor-rasp-pi/9303/18 "2021-03-16T04:37:41Z")

</div>

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.

BUT

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.

---

<div class="post-metadata">

**Author:** ![Robert93820](https://avatars.discourse-cdn.com/v4/letter/r/ac91a4/32.png) [@Robert93820](https://forum.core-electronics.com.au/u/Robert93820)\
**Post date:** [16 March 2021 04:42 UTC](https://forum.core-electronics.com.au/t/blackwater-tank-level-sensor-rasp-pi/9303/19 "2021-03-16T04:42:30Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![Oliver33](https://avatars.discourse-cdn.com/v4/letter/o/a9adbd/32.png) [@Oliver33](https://forum.core-electronics.com.au/u/Oliver33)\
**Post date:** [18 March 2021 07:38 UTC](https://forum.core-electronics.com.au/t/blackwater-tank-level-sensor-rasp-pi/9303/20 "2021-03-18T07:38:50Z")

</div>

> [@Colin153015](#):
>
> I miss out on the nicety of having an on-screen display, but its simple and will work just fine.

KISS - never fails.
