Water level tank

Hello!

I'm trying to make a simple water tank level sensor. I've read lots of pages and I like this simple circuit using the 7 channel Darlington array IC ULN 2004 (Or the ULN2803 that have 8 channels), probes and leds. Link: http://electroschematics.com/5764/simple-water-level-indicator-2/

Probe A Bottom of tank Probe B Upper position of tank Probe C Middle position of tank Probe D Lower position of tank

So I made it yesterday and works like a charm! but I don't know how to connect to my Arduino UNO. I tried connecting to the digital input an analog but I don't realize where is the continuity to control into the arduino. I would like that when the led bright, send the input data to the arduino, and viceversa.

I would appreciate a lot your help. Thanks a lot,

JP Cook

You can connect the pins 14,15,16 to digital ins of the Arduino (assuming these outputs 5V - measure!- otherwise some level converter might be needed). Do not forget to connect GND too

Or you place an LDR near each LED and sample those with analogRead()

Thanks robtillaart for your help ;) Yes, it's 5v from the arduino. So do I have to connect the pins 14,15,16 to digital ins of Arduino, after the IC (before resistor) or after the led? In Arduino I can use:

int inPin = 3;  
int val = 0;     

void setup()
{
  pinMode(inPin, INPUT);      // sets the digital pin 3 as input
}
void loop()
{
  val = digitalRead(inPin);   // read the input pin
}

So I'll read "1" when is ON and "0" when OFF?

Thanks again!

You should use a digital voltmeter to determine the right spot to connect the Arduino.

What about this code

#define HPIN  3
#define MPIN  4
#define LPIN  5

int valH = 0;
int valM = 0;
int valL = 0;
  
void setup()
{
  pinMode(HPIN  , INPUT);      
  pinMode(MPIN  , INPUT);    
  pinMode(LPIN  , INPUT);     

  Serial.begin(115200);
}
void loop()
{
  valH = digitalRead(HPIN);  
  valM = digitalRead(MPIN);  
  valL = digitalRead(LPIN);  

  Serial.print("level: ")
  Serial.print(valH, DEC);
  Serial.print("\t");
  Serial.print(valH, DEC);
  Serial.print("\t");
  Serial.println(valL, DEC);

  if (valL == 1) Serial.println("Alarm!"):  // don't use 3 !!! as it has a special meaning for the bootloader
  
  delay (1000);  
}

// read blink without delay to remove the delay call // read about arrays in the tutorial section to reduce the number of variables.

Pins 14/15/16 will rise to 6 to 8V when the LEDs are off, so you mustn't connect them direct to the Arduino inputs. However, you can connect them via 100K resistors to Arduino inputs.

Thanks dc42 but I'm powering this with 5v from Arduino... not 9V like the diagram.

I think I can connect directly?

The doubt I have is where to connect pins 14,15,16 to digital ins of Arduino, after the IC (before resistor) or after the led.

When I arrive home I would try what you robtillaart said me and I tell you ;)

juampick: The doubt I have is where to connect pins 14,15,16 to digital ins of Arduino, after the IC (before resistor) or after the led.

Connect the junction of the IC and the 100 ohm resistor to the Arduino input pin.

Connect the junction of the IC and the 100 ohm resistor to the Arduino input pin.

I tried it but not work for me :( So I tried with only one input, the HIGH meter. I put in the junction of the IC and the 100ohm resistor but show me: level: 0 0 0. When connecting in the junction of the Led and resistor... show me: level: 1 1 0.

Can you help me? do you know what can be the problem?

Thanks a lot!!

I presume that by 0 you mean LOW. Reading LOW from the pin is what you expect when the associated LED it lit. When the LED is off (water not reached the sensor), it will read HIGH.

Hi... I draw this in fritzing to a better explanation:

And I'm using this code from robtillaart

#define HPIN  3
#define MPIN  4
#define LPIN  5

int valH = 0;
int valM = 0;
int valL = 0;
  
void setup()
{
  pinMode(HPIN  , INPUT);      
  pinMode(MPIN  , INPUT);    
  pinMode(LPIN  , INPUT);     

  Serial.begin(115200);
}
void loop()
{
  valH = digitalRead(HPIN);  
  valM = digitalRead(MPIN);  
  valL = digitalRead(LPIN);  

  Serial.print("level: ");
  Serial.print(valH, DEC);
  Serial.print("\t");
  Serial.print(valH, DEC);
  Serial.print("\t");
  Serial.println(valL, DEC);

  if (valL == 1) Serial.println("Alarm!");  // don't use 3 !!! as it has a special meaning for the bootloader
  
  delay (1000);  
}

But I'm getting wrong values. If I let only the LOW sensor into the water I don't get the changes... from 0 to 1 and viceversa.

What do you think? Thanks again! ;)

I am really really hoping that the red and black wires from the Uno 5v and Ground do not both go to the same rail on the breadboard and that that is a mistake in the pic.... 8)

Yes... Exactly: draw mistake ;) Thanks

As I said before, you need to connect the Arduino inputs to the other ends of the series resistors. I suggest you enable the Arduino internal pullup resistors too. The pins will read in reverse: HIGH = no water, LOW = water.