Float/water level sensor - which PIN can I use to read On/Off?

Hello,

I have this sensor:

and I'd like to use it with arduino to control the water pump.

I also have a relay for arduino.

Do I connect one cable to 5V and the other end to Analogue PIN?

How can I read whether the sensor is passing 5V through?

Thanks in advance.

it is a simple switch, yes?

when the level gets to a point, the circuit opens or closes? hint: you can use your multimeter to check that.

Just check to see if it is normally open or normally closed.

The switch appears to be this one

Any digital pin should be fine, e.g D2 Just connect it between the pin e.g. D2 and GND and enable the internal 22k pullup resistor by

pinMode(2,INPUT);
digitalWrite(2,HIGH);// enable internal 22k pullup

Also remember to debounce the switch (See Arduino Playground - Bounce )

The device is a simple reed switch. You can use any pin you like. The button example in the IDE has all you need and uses pin 2.

Yes, I use one like that and I use the digital pin and the digitalRead().

Any digital pin should be fine, e.g D2 Just connect it between the pin e.g. D2 and GND and enable the internal 22k pullup resistor by

Thats the easy way

When I mount this kind of float switch, do I drill a hole in the side of a bucket, at the bottom or mount it with threads facing up?

I am not using this in a bucket, yet Chinese are not too eager to tell the exact location of the reed switch in the body of this device and how it should be oriented to work.

That depends on the water level you want to measure. If you mount it at the bottom of the bucket then it won't take much water to make it float.

Use a multimeter to test for continuity to determine which position of the float makes the switch open or closed. With most of these types of float switches, you can remove the float from the body and flip it over to reverse the action. So if it is normally closed in the down position, take the float part off and flip it over and put it back on to make it normally closed in the up position.

see this video ! Sensor water level - YouTube