Home Sensor Projects Water sensor example

Water sensor example

by shedboy71

This water sensor is fairly easy to connect this to your Arduino, the requirements are simply VCC (5v), GND and then connect the SIG to one of the Analog pins. In our code example this will be Analog 0.

The water sensor indicates whether the sensor is dry, damp or completely immersed in water by measuring conductivity. The sensor traces have a pull-up resistor of 1 MΩ. The resistor will pull the sensor trace value high until a drop of water shorts the sensor trace to the grounded trace.

water-sensor

Code

The code example is straight forward when the value read on analog pin 0 is higher than 600 the on board led of the arduino is switched on

[codesyntax lang=”cpp”]

int analogPin = 0;
int led = 13;
int val = 0;

void setup()
{
pinMode (led, OUTPUT);
Serial.begin (9600);
}

void loop()
{
val = analogRead(analogPin);
if (val > 600)
{
digitalWrite(led, HIGH);
}
else
{
digitalWrite(led, LOW);
}
Serial.println(val);
delay (100);
}

[/codesyntax]

 

 
Links

arduino water sensor at Amazon Uk

arduino water sensor at Amazon US

You may also like

This website uses cookies to improve your experience. We'll assume you're ok with this, but you can opt-out if you wish. Accept Read More