It's something like this.

It gives either High or Low when only when it is closing the circuit.

Reading already closed circuit does not seem to work.

If I connect to ground it always give LOW no matter if the switch is closed or not.

If I connect to 3.3v, it always give HIGH no matter what.

FYI, I am using 'onoff' nodejs module to do this.

What I am trying to see is that when the circuit is open, it gives LOW, when the circuit is closed, it gives HIGH.

Can it be achieved?


enter image description here

  • If the switch state does not change between high and low then it is not a switch or you have wired it incorrectly. There are plenty of how do I connect a switch tutorials. Follow one and if it doesn't work ask a targeted question. – joan Jul 10 '19 at 9:49
  • Either this is a problem with the sensor (and not the RPi), or I fail to understand what the problem is. – Dmitry Grigoryev Jul 10 '19 at 11:06
  • 1
    @zirho6, I once played with float switches similar to yours. You might like to read my old posts and see if they are helpful: (1) raspberrypi.org/forums/… (2) raspberrypi.org/forums/… (3) raspberrypi.org/forums/… (4) raspberrypi.org/forums/… – tlfong01 Jul 10 '19 at 11:41
  • 1
    For this "right angle" float switch: (1) amazon.com/CHUANGNENG-Pieces-Plastic-Switch-Liquid/dp/…, you can use a multimeter to test the micro switch on or off. The critical word in the ad is "right angle". The sensor at right angles, ie, horizontal and vertical, the micro switch opens or closes. – tlfong01 Jul 10 '19 at 11:51
  • For the rod type of float switch: (1) item.taobao.com/… , what is floating is actually a magnetic core moving along the rod. There are two reed switches, one top, one bottom. If water drops pass the bottom reed switch, the switch sequence is open close open, or vice versa, at the top. So one rod can determine if water is pass the water full or water empty mark. Of course you can use two rods, one for full, another for empty mark, ... There are other types using electromagnetic induction or Hall effects, .. – tlfong01 Jul 10 '19 at 12:43

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.