Water level alarm system Arduino

652 views Asked by At

I have been looking for a nice tutorial to make a ardunio based water level alarm system. I have gone through many pages, i didn't quiet understood much of electronics discussion.

My idea is to keep the groud cable till the bottom of the tank and arrange different length cables to define height and connect them to analogPins.

I shall read '0' when water touches the cable. I would like to use two LEDs one Green if the level of water is below the emergeny level, Red when Arduino does the emergency stop.

I need help with the circuit, I kept my idea into schematic.

enter image description here

Any suggestion will be very much appreciated!

Thank you,

Best Regards, Sai

2

There are 2 answers

3
Delta_G On BEST ANSWER

You'll have to be careful because the water isn't a perfect conductor. It is going to have some resistance. You'll need to understand that resistance and the pull-up or pull-down resistor you use create a voltage divider. The voltage at the center of that divider will have to be greater than 3V in order for the pin to read as HIGH. For that to work you'll need a much weaker pull-up, something more along the lines of a megaohm.

I also like the idea better of having the "switches" here wired as active low. So ground on the bottom of the tank and put the resistors from the pins to +5V. I doubt you can use the internal pull-ups for this as they'd probably be too strong. You'll have to use an external pull-up resistor. In that case the pin reads LOW when it senses water.

The other thing you have to worry about here is electrolysis. You're going to make some hydrogen and oxygen on the wires in the container and you're going to leave behind part of your wire. Usually a sensor like this uses an alternating voltage so the electrolysis takes turns driving both directions and you don't lose material off of your wires.

1
technico On

Basically, the water should act as a switch on your cables. So we can start with the digital button exemple, given with arduino, and rewrite it to fit your needs.

Button

Turns on and off a light emitting diode(LED) connected to digital pin 13, when pressing a pushbutton attached to pin 2.

As we want the led to stop litting when our waterbutton is pushed, we will modifiy the last part of this example.

The circuit:

  • LED attached from pin 13 to ground
  • Water (aka pushbutton) attached to pin 2 and to +5V (not ground here !)
  • 10K resistor attached to pin 2 from ground : (Missing on your shema ! )

Note: on most Arduinos there is already an LED on the board attached to pin 13.

Now let's go to the code :

// constants won't change. They're used here to
// set pin numbers:
const int buttonPin = 2;     // the number of the pushbutton pin
const int ledPin =  13;      // the number of the LED pin

// variables will change:
int buttonState = 0;         // variable for reading the pushbutton status

void setup() {
  // initialize the LED pin as an output:
  pinMode(ledPin, OUTPUT);
  // initialize the pushbutton pin as an input:
  pinMode(buttonPin, INPUT);
}

void loop() {
  // read the state of the pushbutton value:
  buttonState = digitalRead(buttonPin);

  // check if the pushbutton is pressed. If it is, the buttonState is HIGH:
  // I slightly changed the example here, for the led to lit when no water is detected.
  if (buttonState == HIGH) {
   // turn LED off:
    digitalWrite(ledPin, LOW);
  } else {
    // turn LED on:
    digitalWrite(ledPin, HIGH);

  }
}

Now it's up to you to add more "water switchs" and more LEDS to control :)

Note : i choose to use digital pin, as we are looking for a binary decision (is it water or not ?). Maybe analogPin would be more precise, allowing detection of more pure (and less conductive) water ... Go back to analog if digital isn't reliable to detect water ;)