Issue with magnetic switch - Raspberry Pi Forums


hi,

got 1 of those;
https://www.adafruit.com/product/375

working fine, of sudden can't work anymore.

simple python;

code: select all

import time import rpi.gpio io io.setmode(io.bcm) import time  door_pin = 2 io.setup(door_pin, io.in, pull_up_down=io.pud_up)  # activate input pullup  while true:     if io.input(door_pin):         print("door alarm!")     time.sleep(0.5)
working fine last time used it. now,
if disconnect everything
- expected, alarm triggered
if connect on pi keeping magnets apart
- nothing happens, expeting alarm trigger
if connect on pi , keep magnets together
- nothing happens, expected

tested connecting directly on pi board , on breadboard, same result.

can magnet switch broken?! it's simple thing. way check if works?

you can use multimeter test switch.
switch meter lowest ohm scale or use continuity / beeper setting if meter has that.

connect 2 meter leads 2 switch leads. doesn't matter way connect leads.

specs in link reed switch normally open. means switch open (off) when magnet away on closed (on) magnet touching switch.

meter should show low ohms or beep when magnet close switch , show --- or stop beeping when pull magnet away.

if switch on or off broken.


raspberrypi



Comments