Any reason why I can't use 470K or higher as a pullup?

I'm working on battery operated project and want low current consumption . The circuit has a reed switch which when closed will go low and trigger an interrupt. I need a pull-up on the interrupt pin/reed switch so it is high when open, is there any reason why I can't use a high value resistor (470k or even 1Meg) as a pull-up to reduce current flow when the switch is closed?

Could be. A digital input will require a tiny amount of current to reliably read high. A very high pullup resistor might not provide enough and become unreliable, picking up noise from the environment. Why not just try it? Write a sketch to perform a million reads and count the number of low results. Test it by leaving the pin floating, then try 10K pullup, 470K pullup, 1M pullup. Let us know the results.

Paul

is there any reason why I can't use a high value resistor (470k or even 1Meg) as a pull-up to reduce current flow when the switch is closed?

Yes. The larger the pull up resistor the less noise immunity you have. That is the more likely it is to be affected by interference.

Give the length of time a switch is closed for I think you are worrying unnecessary.

Thanks for the replies, the reed switch could be closed for days, it's in a tipping bucket rain gauge and setting it up for momentary action is proving difficult and unreliable.so I was going for either on or off. I also have a hall effect switch chip on order so maybe that will solve the problem.

I'll try the idea of testing it over time, given that the circuit is outdoors and battery operated noise could be quite low.

I have a rain guage that uses a reed switch. The contacts only close momentarily when the bucket/see-saw mechanism tips. Are you sure about yours? Don't forget you need to debounce the reed switch, as you would a pushbutton.

The problem I am having is getting the reed switch and magnet arranged so that it only gives a momentary contact as the bucket tips. Sometimes it latches up, sometimes it doesn't close, sometimes it works fine. I can get it to be more reliable if it is always on at one side and always off at the other. I have tried every possible configuration I can think of for positioning the switch and magnet but always encounter this problem.

May be I need a different sized magnet or reed switch but that just disappears down a rabbit hole of endless combinations...

You could just buy one like mine.

http://www.maplin.co.uk/p/maplin-replacement-rain-gauge-for-n25frn96fyn96gy-n77nf

Use the built-in microcontroller pullup. The value is in 10s of kohms and it saves you a part. Typically, this is not a thing to worry about.

Edit: For your application I would suggest connecting the internal pullup for a short time every once in a while.

Edit 2: Or better yet-connect the reed switch with in series resistor. Then connect one leg of the reed switch to one pin of your micro. Then connect the leg of the resistor to the other leg of the micro. Every once in a while set the one pin to INPUT and the other to OUTPUT HIGH and read the input. Set the output back to low. Done!

given that the circuit is outdoors and battery operated noise could be quite low.

Or it could be higher because of atmospheric electricity.

thegoodhen:
Use the built-in microcontroller pullup. The value is in 10s of kohms and it saves you a part. Typically, this is not a thing to worry about.

Dead right - you use the built-in pullup, and you only enable that (by setting the output HIGH even though it is an input) for a fraction of a millisecond (to account for cable capacitance) in advance to reading the input, then of course, turn it off again and go back to sleep. Debounce (and interference suppression) can be effected by the code I have presented elsewhere over a 10 ms interval.

Put a 2k resistor in series with the line, and diodes to ground and Vcc - or even better, a 5V protective diode.

Thanks for the replies but the reed switch wakes the Arduino so setting the internal pull-up as described is not an option.

sirch: Thanks for the replies but the reed switch wakes the Arduino so setting the internal pull-up as described is not an option.

I don't see any particular reason for it to be done like that though. Why should it wake Arduino? From what I understand, you don't need a super fast (like microsecond kind of fast) reaction time. Just use a watchdog timer to wake it up every now and then and check.

However, be advised that if you are using a real Arduino, trying to save a battery in this manner is like using a pipette to get rid of a flood. Arduino uses a linear regulator, wasting a huge amount of energy in heat, and as such is not suitable for a battery operation.

Not using a "real" arduino, just a ATMega 328 on a board programmed via a USBTinyISP, I have the sleeping current down to 150uA (I KNOW it could go a lot lot lower but there is other stuff on the board).

In a heavy rain storm it is possible that I could be looking for a bucket tip every second or two, so that would mean waking up less than every second to ensure nothing gets missed. And even then how do I know if the bucket has tipped or has just remained in the same place. The contact would appear to be closed in either case, the advantage of using the switch as an interrupt is that the interrupt monitors change of state (falling or rising).

Anyway I think I have an alternative - put a capacitor between the pull-up and the switch. When the Switch closes it discharges the capacitor, pulling the pin low but then the cap charges up again and no more current flows in the cap is grounded again.

If the bucket tips at most once per second, and the ATmega wakes every half second, enables the internal pullup and checks the reed switch, you should never miss a tip.

But how do I know if it has tipped or remained in the same place? Anyway I'm going to try the capacitor idea when I get chance.

sirch: But how do I know if it has tipped or remained in the same place? Anyway I'm going to try the capacitor idea when I get chance.

Maybe I am missing something, but when you check and see it's open, then check again and it's closed, that means it just went closed. If you check and see it's closed, then check again and it's open, it just went open. I believe you can check numerous time per second, and as long as the measurement is quick, the battery will last forever.

About the Arduino-yea, sorry, didn't mean to underestimate you, just wanted to make sure.

Thanks for your efforts but I like I said I am going to try the capacitor idea first. Waking every 250mS or more just to find that nothing has happened (which will generally be the case, even in Britain) just seems wasteful of battery capacity.

sirch:
… but the reed switch wakes the Arduino so setting the internal pull-up as described is not an option.

Why is that then. The arduino does not disable those pins in sleep mode.

The suggestion was to only enable the internal pull-up briefly while a reading was taken. If the MCU is asleep it cannot turn on the internal pull-up and leaving it on all the time means 20k at 3.3V is 165uA, so that about doubles my sleeping current consumption.

sirch:
Thanks for your efforts but I like I said I am going to try the capacitor idea first. Waking every 250mS or more just to find that nothing has happened (which will generally be the case, even in Britain) just seems wasteful of battery capacity.

Now it may seem wasteful, but it’s not that bad. If you wake up every 250 ms and stay awake for 10 ms, that is <50ms awake time per second. You will get several years on an AA battery.

I am not sure about the capacitor idea. It could work, but I don’t think I follow how you want to do it.