Help with contactless water sensor for Arduino

I could use some help with a sensor I bought to detect water level in a container for an Arduino project I’m working on.

I have a couple of these sensors – available everywhere online and sold by a bunch of different vendors. They all appear to be the same general type. Mine is specifically the IP67 one in the ebay link.

I can connect it to a +6 or +12v power supply and the little LED on the unit goes on and off when it senses water, but the output on the signal wire is barely detectable with the Arduino analog port. I’m using a common ground for the sensor and the Arduino. When using a voltmeter across the output and ground, the voltage changes about .01v. The specs say it is supposed to output the same as Vcc when it detects water but that doesn’t seem to be the case for me. (it says output voltage is InVcc.)

I also realize I need to cut that output voltage down for the Arduino to less than 1V.

Has anyone ever worked with one of these? What am I missing or doing wrong?

1 Like

To start with, use 5VDC. Arduino inputs will be 5V or 3.3V inputs. Look up your specific arduino board for the details.

Next, connect a 1K resistor from the output pin to +5VDC. Use the connection between the resistor and the output pin as your output signal. ( ie that junction goes to the Arduino input. )

You may have to set the Arduino pin - some of them have internal pull up resistors as I recall. ( It’s been a while. )

More information can likely be found by googling “Arduino NPN sensor connection”.

Can you provide a data sheet or functional diagram. Is the output of the sensor digital i.e. (VCC or GND) or is it analog (somewhere between the two depending how much is in it?

If the output or arduino requires a pull up or pull down resistor to bias the feedback line to the arduino, you might want to check your value to see how it’s supposed to behave. If you’d like to set up some time at the space. I’d be happy to help you troubleshoot the sensor. Reach out to me with a PM.

All I have is what’s on that ebay listing. I’ll try what tmc4242 suggested and if that doesn’t work I’ll let you know. The Arduino board I’m using is a Feather Huzzah… the analog sensor port is limited to 1 volt. Otherwise it is a 3.3v board.

Thanks for your help and suggestions!

One point - you do not have an analog sensor. Use one of the digital pins.

And since it’s a 3.3V board, you’ll need to look up interfacing 5V to 3.3V logic. Should be lots of guides to that.

Good luck.

The is awesome! We have an RV and the cheap manufacturer supplied sensors for the gray and black water tanks can never be trusted. When I looked at your link I immediately decided to order probably four of them. I work a lot with Arduino-ish devices and have two DMS classes that could be interesting to you.

The Adafruit Huzzah Feather you have is not really an Arduino. It is based on the much more powerful ESP8266 and includes WiFi on board. It is functionally equivalent to the Wemos board I use in my Blynk classes. The good news is that it is compatible with the Arduino IDE.

Here is an excellent article. VCC can be pulled from the Huzzah and connected to the sensor. The OUT return signal will be five volts and must be reduced to 3.3 volts for input to a digital pin. A voltage divider circuit with two resistors will handle this. Let me know if you need specifics.
https://www.dfrobot.com/wiki/index.php/Non-contact_Liquid_Level_Sensor_XKC-Y25-T12V_SKU:_SEN0204

I have two classes that may be interesting.

Arduino: Sensors for Fun and Non-Profit!
https://calendar.dallasmakerspace.org/events/view/5433
(Maybe I should order an extra sensor to use during lab time. We could stick it to the side of the restroom toilet tank and remotely detect when it is flushed. Just joking. Or not.)

I plan to put a Blynk class on the schedule later today for the week of March 26. Here is a description. Arduino: Blynk into the Internet of Things!
https://calendar.dallasmakerspace.org/events/view/5210
This class will show how to connect your project to WiFi and check it from a control panel on your phone from anywhere. Free!

2 Likes

I took your Blynk class a few months ago… this led me down the path of where this is going!

I used “Arduino” generically hoping to get more attention in the title of the post. The Huzzah may or may not be the right device to use for my purposes, but I really wanted the WiFi capability so it could send alerts of the water level if needed.

Do you think the DXRobot adapter is really needed? What I’m really looking for is a schematic of what the connections look like between the sensor and the feather. (a picture of where the wires and resistors go) If the adapter schematic IS that, I guess I’m good to go. My only question on that is why do they show pin 3 from the sensor connector going to GND instead of just connecting it directly to pin 2? (which is also GND, right?) I’m also not sure of what purpose the capacitors play. I have a feeling I’ll still need a voltage divider to keep the signal output to less than 3v for the feather.

One other idea I had was to use this on the Laser chillers so it would send an alert to the laser team if the water level gets low.

Could such a sensor be used to detect a slow draining sink?

hmmm… if there’s’ water in the portion of the drain pipe between the trap and the sink for greater than the time it should normally take to drain, then yes… it should work. (and the sink drain pipe is plastic) Some data gathering on “normal” vs "abnormal’ drain times might be needed to set the proper threshold though.
I think we can make it text you day or night when it happens since you’ll be trained in trap cleanout. You’ll have to be ready to accept some false positives, though.:wink:

I hope the class is leading you down the right path. All opinions here are based on my hobby experience. I think the Adafruit Huzzah is an excellent choice. Adafruit and Sparkfun seem to be the quality vendors with lots of support info. I went with the Wemos D1 Mini because its cheap and I’m buying a bunch for class and home usage. The key is that they both feature an ESP8266 MCU which seems to the the hot hobby WiFi chip for now. I’m confident t will serve your purposes well.

I sent the DXRobot link because it looked like a good article on a similar device. I think the adapter is to make the sensor compatible with their Gravity system. It does not seem needed for input to MCUs. I’m going to order one but delivery is slow. What diagram are you referencing with pin numbers and capacitors?

1 Like

Does the sensor just answer the question: Is water present?

It appears to be a single logic output. I’m expecting it takes more than a film of water on the opposite side of the plastic to trigger, but some of them appear to be adjustable.

I haven’t tested sensitivity with real water yet… I just activate it by putting my hand in front of it (it senses blood too).

I finally got this working. Dead simple if you know what you’re doing but that’s not me.

I connected the brown wire on the sensor to a +6 volt supply, and connected the blue (ground) and black (mode) to ground. Then connected yellow (signal) to a 2Kohm resistor and that to +6v. Yellow also connected to a 1Kohm resistor and connected that to ground. I ran a signal wire from a digital pin on the arduino to the Yellow wire (between the resistors). That then produced 1.7v output which was enough for my 3V max digital input to sense as high.

Then this simple sketch:

int Liquid_level=0;
void setup() {
Serial.begin(115200);
pinMode(15,INPUT);
}

void loop() {
Liquid_level=digitalRead(15);
Serial.print("Liquid_level= ");
Serial.println(Liquid_level,DEC);
delay(500);
}

3 Likes

Congratulations! You can help me with mine when the slow boat from China arrives in about three weeks.

1 Like

Happy to give you one of mine while you wait. I have 3 and only need 1 for
now. I’ll be at the space on Saturday afternoon and will try to remember
to have one with me.

1 Like

That would be wonderful! I probably can not make it Saturday and will be out of town few days. It would be great if you would put it in my storage box in the galley. Its on the west wall - opposite the drink cooler. Three rows up from the bottom and three columns in from the right edge. Label: Brady Pamplin I’ll pick it up and work up a show and tell for the Sensor class on the 19th.