Author Topic: Monitor Reed Switch  (Read 1060 times)

ssmall

  • Full Member
  • ***
  • Posts: 158
  • Country: us
Monitor Reed Switch
« on: March 10, 2019, 03:26:40 PM »
I am working on a project where I am using a Moteino 8Mhz to interface with a Davis rain sensor.  The rain sensor is basically a normally open reed switch that closes every time a small seesaw fills up with enough water to cause it to tip.  I am monitoring the reed switch using INT1 on digital pin 3.  The mode for pin 3 is set to INPUT_PULLUP and the interrupt is set to FALLING.  This setup works correctly to detect when the seesaw tips.  My question is is this a good way to monitor the switch from a power consumption standpoint?  Is it better to setup an external pullup resistor?  if so, what value should be used for the resistor?  I have searched around and it looks like a value of 10K would work but I'm not sure if that would be better than what I am doing now.

The Moteino I am using also has an RFM69CW transceiver and flash memory.  Earlier I fixed an issue where I wasn't sleeping the flash memory properly.  Fixing that issue helped out on power consumption.

Felix

  • Administrator
  • Hero Member
  • *****
  • Posts: 6866
  • Country: us
    • LowPowerLab
Re: Monitor Reed Switch
« Reply #1 on: March 11, 2019, 10:07:52 AM »
The AVR INPUT_PULLUP activates an internal ~50K resistor. I think the datasheets mention a much broader value (20-50K) but in most cases where I had to actually determine it, it ended up around 50K. That might be enough, but if you can afford having another external component that you can always control, then go with a 10K, just watch for any current drain through that resistor.

TomWS

  • Hero Member
  • *****
  • Posts: 1930
Re: Monitor Reed Switch
« Reply #2 on: March 11, 2019, 02:51:37 PM »
The pulse on those tipping rain gauges is pretty short so I wouldn't worry about the resistor current too much.  What I would do is place a cap across the contacts so that they're kept clean every time they close and this will also help debounce the signal.  I'd go with something like 4.7K-10K pullup with a 1-10nF cap.

Also, if there is any separation between your processor and the reed switch (like 2 feet of cable for instance), then I would use an opto isolator or, at least, an ESD protection device to isolate and protect pin 3. 

ssmall

  • Full Member
  • ***
  • Posts: 158
  • Country: us
Re: Monitor Reed Switch
« Reply #3 on: March 12, 2019, 10:18:08 AM »
Thanks for the response to my questions.

If I understand correctly, I need to change digital pin 3 from INPUT_PULLUP to INPUT and implement a circuit like the one below where R1 = 10K:



Also put a 1-10nF cap between the contacts of the reed switch.  I will look into the protection circuit later on.