I'm currently looking for some advice about making my circuit as low power consumption as much as possible.

I need to use three DIP switches in order to set the address of my ATmega328P board in a LoRa custom network.

I've seen that one of the most used solution is to wire up the external pull-up resistors to VCC, as reported below:

Pull-up switches

...but, this approach is extremely inefficient for my purposes (my hardware, during deep-sleep needs to reach 1-5 µA of current draw).

So, my intention is to remove the external pull-up resistors and use the internal pull-up resistors of the digital input of the ATmega328P.

This approach will allow me to enable the internal pull-up resistors only when I need to read the switches status (during boot for a very limited time).

So, theoretically, this will be very efficient and low power.

This will be the resulting schematic (taken from here):

Internal pull-up resistors

This is my idea to solve this issue. Anyway, I've not tested yet. I would be glad if someone will share their thoughts about that.

  • \$\begingroup\$ They make SPDT DIP switches; or is that part already set? \$\endgroup\$
    – vir
    Jul 1, 2021 at 15:20
  • 2
    \$\begingroup\$ Note that with the extrenal resistors 1) the current will flow only when a switch is closed. 2) The value of the extrernal resistors can be made so high that less current is flowing then when using the internal pull-ups. 3) if you connect the top connections of the external resistors not to +5 V but to an I/O used as an output, you can also disable them and only enable them when you poll the inputs. \$\endgroup\$ Jul 1, 2021 at 15:20
  • 2
    \$\begingroup\$ If you only read the state of those switches during boot time and assuming that the circuit isn't rebooting every hour, then it really doesn't matter what you do, internal or external pullups. 100kOhm resistor as external pull-up maybe can be too weak I would use 1 Mohm without worrying about that. An ATMega uses CMOS technology so the inputs are very high ohmic, no need to use less than 1 Mohm. It could be that some RF signal could get in but that is simply solved with a capacitor (10 nF) across the switches. \$\endgroup\$ Jul 1, 2021 at 15:37
  • 5
    \$\begingroup\$ There is no question to answer. You are requesting people to share thoughts. Please edit in an answerable question. \$\endgroup\$
    – Justme
    Jul 1, 2021 at 16:05
  • 2
    \$\begingroup\$ @VirtApp this is a Q&A site ... not a chat forum \$\endgroup\$
    – jsotola
    Jul 1, 2021 at 18:47

4 Answers 4


I don't recommend turning off the pull-up. This has two problems:

  • Input pin is vulnerable to noise pickup
  • The pin can float to a mid-state, causing increased input buffer power

If you can spare one more pin, connect the switch commons to that pin instead of GND, and drive that common low only when reading the switches. Then during the non-reading time the pins are always tied by either the pull-up (switch open) or to the driven-high common (switch closed), yet don't have any standby draw. Like this:


simulate this circuit – Schematic created using CircuitLab

Even then, the internal pull-up (30K or more) is kind of weak, especially if this is to be deployed in a harsh environment. Adding some capacitance to the pin (30pF or so) will bypass noise from the pin and improve its immunity. You can also switch the pins to output mode during the non-reading time for the best possible noise immunity.

But why DIP switches at all? Maybe do away with them altogether and store this state in EEPROM along with your other device configuration info.

But... why bother with even that? Take advantage of the fact that it's a wirelessly-connected device with a unique ID. Idea: use the LoRa device unique identifer (DevEUI) and assign its physical position at the application level as you install it. If the nodes are widely spaced, use a geolocation coordinate; if they're part of a tight array, use some gridding location in the plant or on the equipment.

More about LoRa addressing here: https://www.thethingsnetwork.org/docs/lorawan/addressing/

Finally, a bit of unsolicited advice. As a hardware person it’s easy to fall into the direct, seemingly obvious solution, as DIP switches, jumpers and the like often are. I encourage you to think outside the hardware box and push for a software solution instead. The PC industry struggled for years with jumpers and switches until someone finally said ‘enough’ and Plug’n’Play and its descendants (PCMCIA, Cardbus and PCIe CIS) came into being.

tl; dr: Jumpers are evil. Avoid them if you can.

  • 1
    \$\begingroup\$ +1 Not using dip switchesto begin with is the real answer. \$\endgroup\$ Jul 2, 2021 at 19:53
  • 5
    \$\begingroup\$ In my experience as a computer builder, it took about 15 years for PnP to go from meaning "Plug and Pray" to meaning "Plug and Play". Jumpers are a lot easier to get correct than software autoconfiguration is. \$\endgroup\$
    – Mark
    Jul 2, 2021 at 21:03
  • \$\begingroup\$ If the hardware and CIS tuples were set up correctly, PnP worked pretty well. I designed several ISA and PCMCIA cards that used it. \$\endgroup\$ Jul 2, 2021 at 21:56
  • \$\begingroup\$ There is no problem with switching off pull-ups. In this chip Inputs are disabled in sleep mode and there is no issue with having floating pins while in sleep. And: I don't think the 70% of the answer that is simply a rant against switches belongs here. \$\endgroup\$
    – asdfex
    Jul 3, 2021 at 17:06
  • \$\begingroup\$ The unterminated pins are vulnerable to noise pickup, even if they have a ‘weak keeper’ in the form of a Schmitt trigger input. I’ve written about EMC susceptibility elsewhere, and even with the pull-up enabled that’s not enough to avoid this problem. \$\endgroup\$ Jul 3, 2021 at 17:47

This will work. The internal pull-ups on input pins are for use just like this. Choose I/O pins which can be set as both input and output, and when not reading the switches (99% of the time) you can set that pin to be an output and drive it low to eliminate the current through the internal pull-ups.

  • 1
    \$\begingroup\$ You can turn the pullup resistor OFF and leave the I/O pin as an input. In sleep state this is the lowest current configuration for I/O pins. \$\endgroup\$ Jul 1, 2021 at 19:00
  • 1
    \$\begingroup\$ @JackCreasey, hacktastical's answer gives some good reasons to not leave them as inputs for noise reasons. I'm not familiar with this micro so I trust your judgement about the leakage current in sleep state. As long as the OP doesn't do something silly like enable wake on change or interrupts on those pins, leaving them as inputs should be fine. \$\endgroup\$
    – spuck
    Jul 1, 2021 at 23:38

If you look at the datasheet, section 35.6 you can see that pull-up current will not be negligible, for your use-case - 75uA at 2.7V and 140uA at 5V, if the inputs are grounded. The internal pull-ups are specified to be 20 to 50kOhms (30.2).

An input impedance is not specified, but "analog input resistance" is quoted to be 100MO and the GPIO leakage current 1uA. So it's safe to use an external pull-up of a really high value (1MO). I would not go above this as noise can be easily picked up, especially with long leads and/or a radio nearby.

To make a long story short: for maximum simplicity, I would enable internal pull-ups only while reading the data. For better reliability, I would use 200k-1M external pull-up resistors.


Use the Pull Up resistors to the micro VCC or use the port pull up resistors. The other side of the switches connect to a port pin. Switch the port low when you want to read then set it back high again. If you have a port pin that is driving an indicator it could be used for the switch control but you will need to use a bit of caution. If the indicator is illuminated by driving the port pin low you have it made otherwise you need to reverse the polarities. During normal operation the switches will not care what the port is doing and during setup the cycle will be fast enough the indicator will blink very fast.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.