Pull-up Resistors explained

Summary of Pull-up Resistors explained


This article explains the purpose and selection of pull-up resistors in microcontroller circuits to prevent floating input pins. It details how these resistors maintain a stable high state when buttons are unpressed and ensure a low state when pressed, preventing short circuits. The text covers resistor value selection (typically 10kΩ), internal MCU pull-ups, RC filter effects on signal speed, and calculations using Ohm's Law to limit current.

Parts used in Pull-up Resistor Project:

  • Microcontroller Unit (MCU)
  • Pull-up resistor
  • Button or switch
  • VCC (High voltage source like 3.3V or 5V)
  • Ground connection

What a pull-up actually does

A microcontroller input pin is a very high-impedance sense node. With nothing connected, it does not read “high” or “low” — it reads whatever charge happens to be sitting on the pin, which is why a floating input picks up nearby switching noise and produces a stream of random edges. A resistor from the pin to the supply (or to ground) gives the node a defined default state, and a switch or an open-drain output can then pull it the other way.

That is the whole idea: the resistor defines the idle level, the device only has to sink current to change it. The interesting engineering is in picking the value.

How the resistor sets the level

Take a button wired from the pin to ground, with a resistor from the pin to 5 V. Open, no current flows through the resistor and the pin sits at the supply. Pressed, the pin is shorted to ground and the resistor now carries 5 V ÷ 10 kΩ = 0.5 mA, which is why the resistor exists: without it, pressing the button would short the supply to ground. Ten kilo-ohms is the conventional starting point because it is low enough to beat leakage and noise, and high enough that the wasted current is half a milliamp.

Two constraints set the usable range:

  • Upper limit — leakage and noise. The pin’s input leakage current and any contamination on the board form a divider with the resistor. At 25 °C and a clean board, 1 MΩ still works; on a humid board or a long trace next to a motor, it will not.
  • Lower limit — wasted current and driver capability. A 1 kΩ pull-up on a 5 V rail burns 5 mA the whole time the button is held, and every open-drain device on the same node has to sink that current.

Why open-drain buses need pull-ups

I²C, 1-Wire and many interrupt lines are open-drain: the device can pull the line low, but it cannot drive it high — it only releases it. The line returns high through the resistor, and its rise time is an RC curve set by the resistor and the total bus capacitance. This is where the resistor value stops being a matter of taste.

The I²C specification gives a maximum rise time of 1000 ns in standard mode (100 kHz) and 300 ns in fast mode (400 kHz). Using the usual approximation for a 30 %–70 % rise, tr ≈ 0.85 · R · C:

  • 200 pF of bus capacitance, standard mode: R ≤ 1000 ns ÷ (0.85 × 200 pF) ≈ 5.9 kΩ. A 4.7 kΩ pull-up is comfortable.
  • Same bus, fast mode: R ≤ 300 ns ÷ (0.85 × 200 pF) ≈ 1.76 kΩ. A 4.7 kΩ part is too slow; 1.8 kΩ or lower is needed.
  • 400 pF (the standard-mode maximum), fast mode: the arithmetic gives about 880 Ω, which is below what most devices will sink comfortably. That is why fast mode limits the bus to 400 pF and why long cables and many devices force you to think about capacitance rather than resistor preference.

The other end of the range comes from the driver: the pull-up must not demand more current than the device can sink while still holding its output-low voltage under the specified limit. With VOL(max) = 0.4 V and IOL = 3 mA at 3.3 V, the minimum is (3.3 − 0.4) ÷ 3 mA ≈ 970 Ω. The legal window in fast mode is therefore roughly 1 kΩ to 1.8 kΩ, not 4.7 kΩ.

Internal pull-ups

Most AVR, STM32 and ESP32 pins have a switchable internal pull-up in the 20–50 kΩ range. That is fine for reading a button on the same board, and it is not fine for I²C or 1-Wire: the rise time with even 100 pF of bus capacitance lands in the microseconds, and the bus will produce errors that look like a software bug. If a bus works with internal pull-ups on a short bench cable and fails on the real harness, capacitance is the reason.

Practical rules

  • Buttons and switches: 10 kΩ to the rail, plus a 100 nF capacitor from the pin to ground if the wire is long. Debounce in firmware; the capacitor only removes the worst of the noise.
  • I²C: start at 4.7 kΩ for 100 kHz, drop to 2.2 kΩ or 1.8 kΩ for 400 kHz, and check the rise time with a scope if the bus misbehaves.
  • 1-Wire: 4.7 kΩ is the datasheet value; with parasitic power and long cable, use a stronger pull-up during conversion or a dedicated strong pull-up circuit.
  • Never put a pull-up on a pin configured as a push-pull output that drives low — the resistor becomes a permanent load and, at low values, a way to damage the pin.
  • Level shifting between 5 V and 3.3 V is not a pull-up problem. A resistor does not translate a voltage; use a proper level shifter or an open-drain bus that is only pulled up to the lower rail.

References

  • NXP, UM10204 I²C-bus specification and user manual — rise-time limits, bus capacitance limits, VOL/IOL requirements.
  • Microchip/Atmel, ATmega328P and ATtiny841 datasheets — internal pull-up value range and pin current limits.
  • Maxim/Analog Devices, DS18B20 datasheet — 1-Wire pull-up and strong pull-up requirements.

The formulas and limits above come from those documents; the resistor values are the standard choices that follow from them, not measurements of a particular board.

Quick Solutions to Questions related to Pull-up Resistor Project:

  • What is the primary purpose of a pull-up resistor?
    To prevent floating input pins by ensuring they stay in a defined high or low state while using low current.
  • What is a recommended resistor value for a pull-up resistor?
    A value on the order of 10kΩ is generally recommended to balance power usage and signal reliability.
  • How does a pull-up resistor behave when a button is not pressed?
    The input pin reads a high state as a small amount of current flows from VCC through the resistor to the pin.
  • What happens to the input pin when the button is pressed with a pull-up resistor?
    The pin connects directly to ground, causing current to flow through the resistor to ground and reading a low state.
  • Can microcontrollers have built-in pull-up resistors?
    Yes, many MCUs like the ATmega328 have internal pull-ups that can be enabled using specific code commands.
  • How does resistance value affect response speed?
    Larger resistance values slow down the pin's response to voltage changes because the system acts as an RC filter.
  • Why might a 4MΩ resistor be unsuitable for a pull-up?
    Its resistance is too large and weak, potentially failing to pull the input pin high enough for the MCU to register correctly.
  • What is the general rule for selecting a pull-up resistor relative to input impedance?
    The pull-up resistor should be an order of magnitude less than the input impedance of the pin.
  • How do you calculate the resistor value to limit current to 1mA at 5V?
    Using Ohm's Law, the calculation results in a required resistor value of 5kΩ.
  • Why are lower resistance values like 1k to 4.7KΩ used on USB lines?
    These values are used because fast-changing signals require faster pin response times which higher resistances cannot support.

About The Author

Author avatar

Ibrar Ayyub

I am an experienced technical writer holding a Master's degree in computer science from BZU Multan, Pakistan University. With a background spanning various industries, particularly in home automation and engineering, I have honed my skills in crafting clear and concise content. Proficient in leveraging infographics and diagrams, I strive to simplify complex concepts for readers. My strength lies in thorough research and presenting information in a structured and logical format.

Follow Us:
LinkedinTwitter

Stay in the loop

New AVR projects, tutorials and schematics, every week.

Subscribe Browse projects

Scroll to Top