Tony - I have been reviewing flood sensors late...
I have been reviewing flood sensors lately. So many ways to do this, but I see several i2c sensors that have the qwiic plug on a micro pcb, which is not practical for the boat bilge scenario. I see some sensors with the dual contacts and waterproof wire, which makes most sense. But I don't see how they work, or what is needed to detect if there is water. Has anyone found a good setup that can handle saltwater and has been reliable for detecting water in the bilge? I have bilge pumps on automatic switches, which is fine. I also have Shelly battery powered flood sensors, but the battery lasts for about 3 months before failing. I would like to wire to esp32 and detect water at about four different locations.
46 Replies
I used a float switch like this one: https://amzn.to/4crZbcN in combination with an ESP32 as a high water bilge sensor to alert me that the bilge was full. the code is on my Github page: https://github.com/Techstyleuk/sensesp-engine_monitor/tree/main, in the /////Bilge Monitor///// section
imho… i would try to use an electronic fully sealed sensor that has fly leads , that way its a fully sealed unit,
run the wires to a plug (above bilge water line) and read it with an ESP.
there are various solutions for waterproof plug/sockets… but still better if possible to keep connection above waterline.
or a full sealed float switch - specifically desogned for bilge type operation… fully sealed .. with once again flying leads..
something like this.
these style switches are simply a normally open contact (closes when the float lifts from water level);
get a bunch of these and run wires to your ESP, each to a separate gpio (so that it can alert you to which switch has alarmed) ,
sensESP running on an ESP32, read each switch on a separate GPIO .. send the details of each via a “notification” path on signalk (that will generate alarm,s/notifcation messages) .. once in signalk .. you can then send remote alerts, local alers\ts, local buzzer on rpi et al
I guess I should have been more explicit about bilge water levels. I have dry bilges and would like to detect from zero flood to any level above zero. Two dry contacts that can be submerged in seawater without corroding would be ideal
@Tony check out these https://www.adafruit.com/product/464
you can get them in various configurations from the manufacturer - including sealed for use with chemicalish environments
I've been thinking of combining the etape with some float switches for redundancy. This way I could have a couple of alarm states - one from the esp32 data and then a simple circuit that would bypass the esp32 to trigger a high water alarm on top of it.
I have bilge pumps on float switches and will be sensing current for indicators when the pump is activated. This looks like a great way to be notified when water is initially present
I bought the blue seas bilge monitor a while back, it's just a voltage sense on the pump wire. current monitoring would be nice since you can tell if the pump is working
@Tony there's another liquid sensor that adafruit carries but I don't think it's as good for bilge submersion
There must be some probe type sensor that would work. I looked at the $40 but seems a bit expensive for wiring a water sensor.
if you are looking for something that will trigger when there is ANY water present you could look at a basement flood sensor like this one: https://amzn.to/3VFnRIK
Any idea how this works? Pulse? I2c? Ohms?
the description on Amazon has wiring suggestions and states it is perfect for Arduino, which means it should work fine with Pi and ESP32. The output is open circuit and then connection via a 1.4 M ohm when water is present. it says 5-12V but I would bet it works with 3.3V. You should be able to connect the red wire to 3.3V, the white wire to a digital input that is pulled down and you should see the pin register as 1 when water is there, 0 when not
Thanks Jason. I will buy these and give them a try.
when I was testing my bilge sensor code I created a standalone version for just the bilge sensor, I just uploaded it for you to use as a start: https://github.com/Techstyleuk/bilgeSensor
So that's just using wireless on the esp32 to talk to the signalk server? No nmea2k connectivity... hmm. Well at least I can test that at home without additional hardware.
NMEA 2000 is a little harder and you would have to work out the PGN for the bilge level. I do have code for a NMEA2000 battery monitor that I made for a friend that doesn’t have a SigK server onboard - you could use that as an example. You can also have SignalK send it out if the server is connected to the NMEA2000 network
Much easier to send to signalk and convert to all kinds of formats from there. I am sending to influx cloud and monitoring via grafana cloud, then signaling alerts to my phone via slack
I've got a couple of esp32 sailor hats in my parts bin on the boat, complete with nmea2k interfaces, etc. Just haven't gotten to them yet.
Just trying this out. I've been putting off esp32 dev for way too long. That takes quite a while to compile
im using “pushover” (plugin for sk) and a free account to send alerts to ipad (ios) and phone (android) .. works really well.
very fast, customisable alert types,
ooh I need to check that out
I got your example working with my dev setup - signalk on openplotter on my vm host/homelab box and my ESP32 chattering over wifi to it. The logic is backwards for a typical bilge switch, but I'm impressed by the update speed
I know it's trivial to change, just wanted to mention it
do you mean that the pin should be low (0) when water is present or what?
Typical float switch is open/disconnected when no water is present. They close the circuit when they trigger. In the current code, when the circuit is open, the esp32 reports water present.
Hmm, I don't remember, but I just looked at my install video and it does appear to be wrong (meaning, showing water when there is not), so I must have corrected it and not updated the code on github, sorry about that, looks right on my boat now:
I tried using the flood sensor, but I am not getting consistent results. Using the HALMET library for digital input, I am unable to trigger the flood state.
I used D1 input, and it's about the same. If I immerse the sensor, it changes if I am in a fresh state. I am wondering if the alarm will only trigger once.
I also tried the LambdaTransform to log the input value, but it's jumping erratically between 0 and 1
Doing nothing I get inconsistent results:
Tony have you reviewed https://docs.hatlabs.fi/halmet/docs/usage/
In particular the Halmet has hardware pullup/down resistors onboard...
you need to solder the jumper to enable it
It's got extra filtering on the inputs - you can't connect a normal esp32 board to +-32v...
Missed that part. I will try soldering. Thanks
well let's be fair - hatlabs really needs to make it easier to find docs from the product page
Which jumper should be soldered? There are three per digital input
what are you connecting it to
A dedicated float switch or tapping the bilge pump power line?
if it's Ground-----Switch-----Helmet input, then you'll want to solder the PUP (short for pull up)
Hmm maybe I have it wrong: the description seems to indicate that it can have resistance as a measurement
yeah that's not an on/off switch
I wonder if this should be read as analog instead with a resistance range as a Boolean
I looked up a review...
Just received this product. Using it to automatically add water to a pool. Connected it to an 12 bit ADC. A 10M resistor divider is required.
Might as well go analog then
@Jason_SV.Apres|Hunter336|WI how did you get this working using digital input?
I will suggest snagging a spare esp32 and a breadboard to build test circuits. Then once you finalize it, tranfer it over to the halmet
in one of the messages earlier i said "the description on Amazon has wiring suggestions and states it is perfect for Arduino, which means it should work fine with Pi and ESP32. The output is open circuit and then connection via a 1.4 M ohm when water is present. it says 5-12V but I would bet it works with 3.3V. You should be able to connect the red wire to 3.3V, the white wire to a digital input that is pulled down and you should see the pin register as 1 when water is there, 0 when not".
if you do this and it stays low, then check the voltage, if it is around 1.6-1.8, you may want to connect the red wire to 5V instead, this will get the voltage up higher when connected, you have to be careful doing this though as if it goes over 3.3v, you could damage the digital input. you could add a 3.3v zener diode to protect it I have it working with a different switch that is an on/off switch, and then I have the sense pin set to pull up, then the other wire is connected to ground.
if you do this and it stays low, then check the voltage, if it is around 1.6-1.8, you may want to connect the red wire to 5V instead, this will get the voltage up higher when connected, you have to be careful doing this though as if it goes over 3.3v, you could damage the digital input. you could add a 3.3v zener diode to protect it I have it working with a different switch that is an on/off switch, and then I have the sense pin set to pull up, then the other wire is connected to ground.
I couldn’t get it working with either analog or digital. I haven’t tried soldering pull down for the digital input but I did use a 3.3v from i2c and D1 ground without any success. I am not sure if there is another 3.3 or 5v pin I can use. Also if this ends up working I’m concerned the current will corrode my steel tanks. I’m wondering if there is a way to pulse current on intervals instead of constant current. One tenth of a second every thirty seconds or something
Looks like it might be 5v with a pull down jumper. I'll try it
Any idea where 5v lives on the HALMET header? @Matti Airas
You should be able to schedule it, may take a bit of coding but a good challenge, there are examples of scheduling stuff in some of my engine code, and battery code - mainly when to schedule sensor or NMEA2000 messages. but do you need to? when there is no water, there will be no current flowing
if you are powering the HALMET with NMEA2000 or another 12v source, you could borrow a bit of this and do this with a zener diode:
i think there needs to be a current limit resistor in the circuit… the zener will see 12V across it … with nothing (except capacity of “12V” supply) to limit its reverse breakdown current flow.
the Float switch he has picked has a 1.4M Ohm resistor when closed
ah perfect …. ! i just looked at the schematic … and thought .. hmm that zener is about to become a fuse.. haha