Using an Arduino to automatically sense the water level and turn on a pump
That heat is bad. And my air conditioner loves dripping wetting the floor. Last year I tried to solve it with a water level sensor, an Arduino, and a relay to turn the power on and off automatically.
But the sensor corroded after just a few months.
Now with the help of my 3D printer and a magnetic field sensor, I try to find a different solution that doesn’t put any electronics in the water, and will last much longer.
In this video I show the process of automating my water pump, creating a water level and sensor.
//NOTE: I'm using the A0 and A5, which are Analog pins as Digital Pins. The only reason is convinience, as putting the cables on that side of the Arduino made it fit better inside the case.
int input = A0; //Magnetic Sensor In
int output = A5; //Relay Out
int maxSecondsOn = 300;
int minSecondsOn = 60;
int state = 0;
int secondsOn = 0;
Serial.print("Min Seconds On: ");
Serial.print("Max Seconds On: ");
int newState = !digitalRead(input); // The value is inverted (hence the ! sign) because I used the Arduino INPUT_PULLUP. Which means that it's normally HIGH unless the sensor is tripped.
// This is to avoid introducing an extra resistor into the circuit.
Serial.print("Output State: ");
Serial.print(" Sensor state: ");
Serial.print(" Seconds On: ");
if(state == 1)
secondsOn = secondsOn + 1;
if(secondsOn > maxSecondsOn)
newState = 0;
if(secondsOn < minSecondsOn)
newState = 1;
if(newState != state) //Status Changed
Serial.print("Changing Output to ");
state = newState;
secondsOn = 0;