I would like to use a res pi 0 for a wet experiment in my lab. I need the device to indicate when water seeped out through a water resistant membrane. Basically the method is straight forward, as soon as the water gets out - my experiment is over and I only need the device to register the time (simple enough). However, in order for the device to recognize the end of the experiment, I need to close a circuit with the water and let the device know. What I am missing is how to let the device know that a circuit is closed? Should I have some sort of relay? Can someone help me with this?


edit I guess my TL;DR question will be: can I connect an analog sensor to res pi and get an on\off data? edit

  • 1
    You might consider a "water detector" (rain detector, moisture detector, etc). The moisture detector outputs an analogue or digital signal to Rpi or Arduino, which registered the time. Reference: raspberrypi.stackexchange.com/questions/98491/…
    – tlfong01
    Dec 15, 2021 at 14:14

2 Answers 2


Wrt the question" can I connect an analog sensor to res pi and get an on\off data?

No, the Raspberry Pi does not have analog inputs that you can use. It only has digital IO through the GPIO pins. You will need to find an interface circuit or device that will sense the presence of water, and provide either a switch closure or an active HI or LOW output that can be used as an input to the RPi.

That said, the resistivity of water varies over a wide range depending upon the concentration of minerals/impurities that are dissolved in the water. In other words, you can build a circuit that will detect moisture and provide a digital signal compatible with your RPi GPIO. Lots of ideas available online for a do-it-yourself water sensor - or you can buy one.


They make capacitive sensors that will give you a go or no go signal. They can be purchased from your favorite china supplier for a few dollars and no analog input is needed. This is the model I use: XKC Y25 T12V Liquid Level Sensor Switch Detector Water Non Contact Manufacturer Induction Stick Type Durable Y25-T12V XKC-Y25-V it is under $5.00. It has been operating for several years without any problem. Put plastic or some other water tolerant material under the leak and place this on it. When it leaks you will know. To make life easier it has a LED to tell you the status.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.