I use a Pi3 Model B as a home alarm. For this reason, I use 11 of the GPIOs as inputs connected to reed switches (and a couple more with similar circuitry connected to 12V PIRs -)
The diagram for each GPIO is the following :
I use NO reed switches and when a door is open, the GPIO detects logic 1 (3V3).
I generally use relatively long cables (5-15 meters), shielded/grounded.
The alarm works relatively well, although sometimes I get some faulty indications (drops from 1 to 0) when I turn on/off some electrical equipment in the house which I am trying to mitigate (perhaps problem with the house grounding).
With the current circuitry, I use 4K7 resistors as pullups. The 1K resistor is used for protection in case I accidentally set it the GPIO as OUTPUT.
I am currently upgrading the alarm (basically replacing the perforated board I used with a PCB one) so my question is the following :
- Should I use 1K and 4K7 resistors or should I use different values? While testing I used 1K and 10K resistors but I read somewhere that for long wiring I should prefer to use 4K7 or even 2K2 instead of 1K. So in practice I used 4K7. I suppose that this, compared to the 10K, increases the current flowing when the reed switch is closed. (The cabling's resistance is max a couple of Ohms).
Is there a reason to prefer 10K or 2K2 over 4K7? [list=]If I use 2K2, the current per GPIO will be 1,5mA. So 11 GPIOs will draw approx. 16.5mA. I guess it is fine, isn't it?[/list] [list]If I use 10K, the current per GPIO will be 0,33mA. So 11 GPIOs will draw approx. 4mA.[/list] [list]With 4K7, the current per GPIO will be 0,7mA. So 11 GPIOs draw approx. 7,7mA.[/list]
Theoretically, I could use 10K but with such current and circuitry, are there any drawbacks due to the small current flow when the reed switch is off (doors closed). Is this current flow indeed small? Additionally, any drawbacks concerning noise/interference, though the cables are shielded?
I aim to use again 4K7 but thought I'd ask just to hear some other opinions...