Making a water switch

Hello! Since the first project with the ultrasonic sensor didn't work out, my uncle suggested making a circuit that notifies him when the animals' water is low. Since we don't have an actual sensor for that (I know one exists though), I'm actually going to make a very simple circuit, by having the water act as a switch, as tap water can actually conduct electricity pretty well. Since I'm also an advocate for all animals, I tried my best to research what current is the threshold for feeling. Since it varies from 2mA to 5mA among humans, I decided to reduce the current down to a safe 10µA. I tested this with some basic code to read back the input values. At first, it would flicker between one and zero when not in the water, and 0 when in water. Now the results are inconsistent. sometimes it would be 0 out of the water, or a solid 1 whether or not it's in the water. The circuit has three 12Ω resistors and two 10Ω resistors all placed in series, it's that simple.

Here's the code I used, feel free to suggest any changes!

void setup() {
  // initialize serial communication at 9600 bits per second:
  pinMode(7, INPUT);
  Serial.begin(9600);
}


void loop() {
  // read the input on analog pin 0:
  long sensorValue = digitalRead(7);

    Serial.println(sensorValue)
  delay(1);        
}

Update: All of these comments are helpful. Thank you so much, especially the two that informed me about electrolytic corrosion. That looks like a valid concern that can be harmful to both the project and the user. Unless I can find an efficient way to neutralize that issue, I may consider changing the project... again...

In the case of that, may I ask those that are willing to help what projects I can work on? I don't have ideas as of now given what I have. Sorry if it's asking much.
The components:

Light-Emitting Diodes (Total: 15 + 1 LED-RGB)
4-digit 7-segment display
1-digit 7-segment display
DHT11 Temperature Sensor (1)
PIR Motion Sensor (1)
IC 74HC595N 16-pin DIP (1)
L293D Chip (1)
Relay Module (1)
8x8 LED Matrix (1)
Micro Servo Motor (1)
Small DC Motor (1)
Photo Resistor (3)
LCD1602 Display (1)
Ball Tilt Sensor (2)
Button Switch (4)
Flame Sensor (1)
IR Remote Control (1)
IR Reciever (1)
HC-SR04 Ultrasonic Sensor (1)

Technically speaking, these are definitely more than enough to start a project (ex. making a fan that turns on when someone is in a certain proximity), I however, have a little bit of OCD, and want to start a project that uses as many of these as possible. I like to make a creation that's complex, and useful. I know that there is a project hub that I can go to, but I can't find a project that has only any of these. Thank you all so much for the assistance!

Use

pinMode(7, INPUT_PULLUP);

Show us a good schematic of your circuit.
Show us a good image of your ‘actual’ wiring.
Give links to components.
Posting images:

I have a float valve that turns on the water when the level gets low. No Arduino necessary. No electricity necessary. Works in daylight or dark. Why not use something similar? Or is this a test of your ability?

Paul

Over a long time you will get electrolytic action and produce metal
Ions in the water - at least making it taste off or possibly worse ...
I’d use a float switch or weight the water .
Better still visit your pets more often

Since I'm also an advocate for all animals, I tried my best to research what current is the threshold for feeling. Since it varies from 2mA to 5mA among humans, I decided to reduce the current down to a safe 10µA.

You are misunderstanding something; the current, however much it is, will flow between the electrodes, not to the mouth of the animal that is drinking. As long as the voltage between the electrodes and the animal is low enough to be harmless then it won't harm them.

Electrolytic corrosion of your electrodes will be your problem.

Back in the good old days when I worked in the electrical wholesaler sector Omron Electronics made a range of floatless level sensors, these comprised a controller and three stainless steel probes.
The three probes were different lengths and gave a low and high water level reading. These worked great in water tanks where there was a large differential between high and low water levels, but in a trough maybe not so well.
These were designed for drinking water and long life and so stainless steel wire would seem to be the solution for the probes. The water would be getting replaced pretty regularly through consumption and possibly evaporation so I don't see a harmful build up of Ions being an issue.
What animals are you watering?
How big are the water containers and are they close to a power supply?
Float switches are ideal maintenance free level controllers for larger watering troughs etc, but they also have limitations.

I don't know how large your water tank is, but if it's under 400lb, you could consider my solution to my water softener. I used 4 load cells rated at 50KG each, HX711 (24bit ADC) and Wemos Pro Mini to record the high and low weights as it recycles and if the low weight is below threshold I add a few bags of salt. I send the data to ThingSpeak so I can check it from time to time.

If you want to know the water level, it's related to weight, you avoid galvanic issues, zapping animals and the circuit is super simple.

Kiwi_Bloke:
Back in the good old days when I worked in the electrical wholesaler sector Omron Electronics made a range of floatless level sensors, these comprised a controller and three stainless steel probes.
The three probes were different lengths and gave a low and high water level reading. These worked great in water tanks where there was a large differential between high and low water levels, but in a trough maybe not so well.
These were designed for drinking water and long life and so stainless steel wire would seem to be the solution for the probes. The water would be getting replaced pretty regularly through consumption and possibly evaporation so I don’t see a harmful build up of Ions being an issue.
What animals are you watering?
How big are the water containers and are they close to a power supply?
Float switches are ideal maintenance free level controllers for larger watering troughs etc, but they also have limitations.

In the house lives two cats and a dog. The dog is a shepherding breed, so I would say that she’s mid-size. There are one adult cat and one adolescent/kitten. Thank you for the feedback! I was trying to create a float sensor using only the kit I have.

Regardless of the system used, if there is any concern for the animals, you will need to do periodic checks to see nothing has failed.
The period would depend on many aspects.
A mechanical float is many time less prone to failure that any electronic device.

[

](37.5cm Liquid Water Level Sensor Right Angle Float Switch Mini Float Switch Contains water oil chemical medium|switch|medium - AliExpress)

You could use one of the "Ball Tilt Sensor (2)"

If you still want to use electrodes, try as large of piece of wire you can get at your local hardware store then check the level on a timed basis maybe every 5 minutes or so - doubt your pets could drink the dish empty in that time

Others have used a two liter pop bottle mounted to the side upside down - when the mouth of the bottle is underwater no more water will come out

saildude:
Others have used a two liter pop bottle mounted to the side upside down - when the mouth of the bottle is underwater no more water will come out

This is how we water the rabbits, a really simple cheap solution.

Kiwi_Bloke:
This is how we water the rabbits, a really simple cheap solution.

Too simple for contributors here!

If you must use electrodes, put a 1 µF capacitor (not electrolytic) in series with the "sense" electrode, the other being grounded. Connect this to the Arduino input, set it as OUTPUT (and LOW) in setup(). To occasionally test it, set it to INPUT_PULLUP and read it, then immediately write it as LOW, then set it to OUTPUT again.

So most of the time, the capacitor will be discharged, for the brief time you read it, it will not charge sufficiently to alter the reading and it will then be discharged again. There will be no net current to cause electrolysis. :grinning:

No other resistors needed, but safety diodes between the pin and ground and 5 V may be a good idea (though in operation, the pin is an OUTPUT and grounded by the internal drivers with their 25 Ohm impedance).