3

I am creating a self watering indoor garden with a Raspberry Pi 3 B+, but for the way I'm building it, I need an accurate level detection. The water will be fed into this container, and then this pump will pump the water.

enter image description here

For different reasons, which I won't explain not to make this post long, I need to accurately detect when the water reaches two different levels. I tried this sensor connected to the MCP3008:

enter image description here

But it always returns different readings, so it's never accurate. I tried different codes, using the SPI and the normal GPIO, but it still returns a crazy reading. The ultrasonic sensor wouldn't work for me because this container will be closed and the water would touch it.

I read about using 2 wires, like on this trhead Detect water level and I think it would be ideal for this project, but how can I build that? I couldn't understand from he way he explained. Or is that sensor I'm using supposed to be accurate and I'm doing something wrong? I used these two ways of wiring and code:

https://learn.adafruit.com/raspberry-pi-analog-to-digital-converters/mcp3008

http://kookye.com/2017/06/01/%E5%9F%BA%E4%BA%8E%E6%A0%91%E8%8E%93%E6%B4%BE%E7%9A%84%E6%B0%B4%E4%BD%8D%E6%BA%A2%E5%87%BA%E6%A3%80%E6%B5%8B%E5%99%A8/

I appreciate any help.

| improve this question | | | | |
2

There are a lot of potential ways to do this. Based on this answer I'd suggest this:

schematic

simulate this circuit – Schematic created using CircuitLab

What's shown in the schematic as a 20M ohm resistor is actually just two wires which are about 1cm apart. They should be arranged so that they just touch the water when the water gets to the desired level. If you want two levels, build two circuits.

The 3.3V comes from the Raspberry Pi's power supply (the whole circuit consumes less than 0.5mA) and Vout is connected to a GPIO input pin on the Pi. A high voltage (logic 1 = 3.3V) indicates no water and a low voltage (logic 0 = 0V) indicates water.

| improve this answer | | | | |
  • This is pretty much what I was looking for. I actually stopped the project at this point. I will give it a go. Thanks for your answer. – Filcp Nov 22 '18 at 1:08
1

Roller Ball Tilt Switch

Perhaps you can make use of the SW-520D basic tilt switch which detects orientation.

Inside the can is a ball that make contact with the pins when the case is upright. Tilt the case over and the balls don’t touch, thus not making a connection.

You need to make some sort of lever with one end connected to the tile sensor and another end to a ball which floats and tilts the lever when the water level reaches a particular level.

Magnetic Tilt Switch

I never heard of this switch mentioned in the comment. So I googled to know more.

Float Level Switches & Sensors with Magnetic Reed Switches are accurate to 1/8 inch. When the liquid level rises or falls, a stationary sensor detects the change of the magnetic field of the floating magnet and the accuracy can be as small as 1/8 inch, ...

Mercury Tilt Switch

I read the Arduino Mercury Tilt Switch Tutorial and found mercury switch is very similar to roller ball switch. The disadvantages I know about mercury switch is that mercury is toxic and the glass container is not that strong comparing to the roller ball metal container.

| improve this answer | | | | |
  • 1
    Seems complex, why not just use a mercury switch? – Glen Yates May 16 '18 at 13:08
  • @GlenYates: Yes, I agree mercury switch is simple, cheap, and has no bouncing problem. The 2 metal balls thing is complicated, expensive, and bouncing. But I still like 2 metal balls. Why? – tlfong01 May 17 '18 at 0:19

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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