Reed Switch and MotionMote

Started by Stark, April 25, 2016, 06:18:09 AM

Stark

I have added a reed switch to a MotionMote kit to allow door monitoring. The reed is connected to VCC, GND via a 10K resistor and to the A5 IO pin (these are spare pins available for the OLED).

The MotionMote PIR uses the spare hardware interrupt. So in order to generate an interrupt for the Reed switch I am using pin change interrupts. When the pin change ISR is called I am then reading whether I have HIGH or LOW on the reed which corresponds with open or closed and sends message.

All works fine and well. I can get a robust and quick response on both the PIR and Reed switch.
BUT....if there are no interrupts for say a longer idle period then the reed stops  activating (or is very delayed)? The PIR works fine though.

  • I have tried deactivating the hardware PIR interrupt to see if there are some conflicting timings. Not solved.
  • Are there known issues with pin change interrupts and lowpower sleep/hardware interrupts ?
  • After appearing to stop working the pin change interrupt fires but very delayed. No pattern but waiting around 2 minutes. This might always be the case but not fully checked.
  • I am using an NO/NC reed switch. This gives a closed low (reed open) and open high (reed closed). In this case the reed is primarily repelled...Has anyone had experience of NC reeds getting stuck?
  • The reed is placed hard against the PIR capacitor. Do capacitors generate a magnetic field?
I will try a different reed swith type and logic however any debug tips would be appreciated.

Felix

Maybe a quick look at the signal generated by the reed on a scope would shed some light. I can see how that is hard to do since it works for a while.
If someone else who's used reed switches with Moteino has any suggestions please share.

Stark

As an update I got back home to the same non-responsive Reed trigger. However listening for a tell tale click it seems like the reed I am using is defective. Resorting to percussive maintenance  :D, giving it a flick starts it working again. So this rules out in my mind any coding issues.


  • It may be some magnetic issues with the PIR so when I have some new reeds I will replace and test more.

I am also using the NC normally closed wiring, i.e. the reed is open when the magnet is near (door closed).

My setup is as follows with a pull down to keep the signal low when the door is closed.

VCC
  |
   /  Reed (NC) open when door closed
  |
  |-------A5
  |
10K
  |
GND


  • Is this a good choice? Stupid question but doesn't a pull up option consume power when the switch is open?


Felix

INPUT = HIGH-Z so you're good. Only when the door is open there is flow between VCC and GND through the 10k. If VCC=3.3v then your leakage is 330uA. You could probably get by with a 100K or even 1Mohm.

emjay

@stark,

The contact closure may well lack sufficient wetting current https://en.wikipedia.org/wiki/Wetting_current needed to break down the oxide growth on the mating faces. Depends a lot on the quality of the reed switch - the better units are gold flashed with argon fill - YMMV with FleaBay parts.


Stark

Thanks for your assistance and knowledge. Much appreciated.

I can currently report success by replacing the reed switch but will be keeping an eye on the reliability  :-\ .

Regarding the reed switch type and quality. For the reasons of power saving (assuming my pull down, and switch open when door closed logic is beneficial for this) I need an NC type reed switch. These are not readily available, as NO seems the common variety. As a result I have found a changeover NC/NO type which allows the choice of operation. This is an ebay job so time will tell on the quality....maximum current carry is 0.2A, maximum switching current is 0.08A. No information on wetting (minimum) current.

Will report back if any developments, however door monitoring is a nice addition for me and possibly others. Especially as it uses the already trusted MotionMote with minimal modification.

Currently I have the reed on the left side in the enclosure and I have omitted the switch (always on jumper set) and button. However depending how you need it handed it could probably fit on the right and the button and switch could be retained.  I am setting it up with my developing AlarmMote.

Thanks again.