I'm trying to determine the minimum value of pull resistor for Arduino Uno

The datasheets says for arduino; VOL = 0,4 for IOL = 20 mA. (VDD = 5V)

For formula for calculation of minimal pull-up is: Rmin=Vcc−0.4V/20mA = 4,6V / 20mA = 230 ohms.

But I saw that people use 0,4V for 3mA. Than the minimal value is 1,6K ohms.

So whats the minimum value of pull-up for arduino?

(also my slave has 0,4 Vol for 20 mA IOL)

  • I don't follow what you're asking. What's this "0,4 Vol" and what relevance does 20mA have to anything? – Majenko May 28 '18 at 14:59
  • They come from the datasheet of arduino UNO – Kono May 28 '18 at 15:05
  • I get the feeling you are regurgitating values you read without understanding what they mean and the context they are used in. I still don't know what this "0,4 Vol" is. – Majenko May 28 '18 at 15:06
  • And the concept of "minimum pullup" for I2C is meaningless. – Majenko May 28 '18 at 15:13
  • Please check: ti.com/lit/an/slva689/slva689.pdf. I need to determine the minimum pull-up value. The maximum pull up value depends on the max bus capacitance – Kono May 28 '18 at 15:17

The full datasheet of the atmega328p can be found here: https://www.microchip.com/wwwproducts/en/ATmega328P.
It is called "ATmega328/P AVR MCU with picoPower Technology Data Sheet".

In section "32.7 Two-Wire Serial Interface Characteristics" in table 32-10 on page 372 it shows different voltage levels for the input.

On page 110 it says: "When the TWEN bit in TWCR is set (one) to enable the 2-wire Serial Interface, pin PC4 is disconnected from the port and becomes the Serial Data I/O pin for the 2-wire Serial Interface. In this mode, there is a spike filter on the pin to suppress spikes shorter than 50 ns on the input signal, and the pin is driven by an open drain driver with slew-rate limitation".

I wrote here before that the i2c (the twi hardware inside the microcontroller) did not use the digital pin hardware. However, the i2c pins can still sink a lot of current. Thanks to @Berkay for noticing the same behaviour of the sink current as a normal digital pin.

According to the datasheet the atmega328p of the Arduino uno might not use the digital pin hardware for i2c. It is not known if the same mosfet circuit is used with the same (large) sink current. Perhaps the chip uses a similar mosfet circuit with added slew rate for the output and added spike filter for the input. Perhaps the same mosfet of the digital pin is used after all.

In the Arduino sketch, calling Wire.begin turns on the dedicated i2c hardware in the atmega328p chip. The sink current and voltage levels are according to the i2c specifications.
As you can see in the i2c tutorial by Nick Gammon, the Arduino can sink more than 3 mA.

When the pullup resistors are too low, for example for a sink current of 4 mA, the Arduino uno can handle that, but the slave might not.

When all the pullup resistors are combined, the required sink current can be calculated. The maximum is 3 mA to meet the i2c specifications. To compensate for wire capacitance the i2c bus speed can be lowered.

The i2c bus is not ment to go into a cable, it is not ment for long wires. A cat6 cable is 46 pF/m. That means your 800 pF is for 17 meters cable? That is not what the i2c bus is for. It is for 17 centimeters. The rule of thumb is maximum 50 cm for a normal 100 kHz to 400 kHz i2c bus.

  • I think you’re not right. The arduino i2c pins can sink up to 20 mA with max VOL 1V. Thats also what you see in the link. Arduino can easy sink 10 mA – Kono May 28 '18 at 23:22
  • This means that the images you see in the link; confirm that arduino is just using digital pin hardware for I2C – Kono May 28 '18 at 23:30
  • By sinking 10 mA, the 'low level' lift till 0,5V. That's acceptable according the I2C spec. (VIL is 1,5V for communication). Pull-up R is about 500 ohms – Kono May 28 '18 at 23:46
  • @Berkay thanks, I have changed my answer a lot. According to the datasheet the digital pin is disconnected. But that can be done before the output stage. However, a i2c bus is for a maximum sink current of 3 mA. You should fix your problem in an other way, perhaps with RS485. – Jot May 29 '18 at 6:08
  • I2c 3ma is a typical value for most of i2c devices. There are some devices who can sink much more like 20mA. Why should i use 3mA for my calculations then? – Kono May 29 '18 at 9:17

I assume you want to work out the minimum value for a pullup resistor that will give a voltage below VIL for an IO pin in open-drain mode.

That is not a simple task, chiefly because you don't know the ON resistance (RDSON) of the low-side MOSFET in the chip.

It's possible to come up with a rough estimate (see here) though.

With VIL of 1.5V and maximum current of 40mA that's an estimated theoretical resistance of 1.5/0.04 = 37.5Ω.

Note: this is just an estimate based on the absolute maximum and DC Characteristics values from the datasheet.

So if we take that value as actually true you can work out the upper half of a voltage divider that would result in 1.5V coming out. There's two ways of doing that - using the resistance or using the current.

Taking the resistance R1=R2(Vin/Vout-1), 37.5 x (5/1.5-1) = 87.5Ω.

If you want to do it with the current (40mA "absolute maximum"), then R=V/I = (5-1.5) / 0.04 = 87.5Ω.

However, that comes with a big caveat. The IO pin, while it can, for short periods, sink 40mA, it's not designed to do that for long periods. For that 25mA is the recommended maximum. So a resistor should be chosen that keeps the current below 25mA.

Assuming 37.5Ω for the MOSFET resistance, and 25mA through it, that gives a voltage drop across it of 0.94V (well below VIL). The upper resistor in that divider would then be (5-0.94)/0.025=162.5Ω

So to sum up:

  • The absolute minimum resistor would be 87.5Ω
  • The recommended minimum resistor would be 162.5Ω
  • The resistor you would choose to use would bear no real relationship to those values since you would normally choose something more sensible, like 3.3kΩ unless you wanted to run the I2C bus at insanely high speeds or with massive load capacitances.

You really don't need to know the theoretical minimum. You know the maximum already, and all you really need to know is "is the value I'd like to use safe for the IO pin" - i.e., does it draw less than 20mA?

For that you can ignore all the other values. All you care about is your resistance, the Vcc voltage, and the resultant current.

For instance, for a 900Ω resistor with 5V across it you get 5.6mA. You know for a fact that you can never have more than 5.6mA regardless of the resistance of the MOSFET - it can only go down from there.

5.6mA is below the recommended maximum of 20mA, so you're perfectly safe with that resistor.

  • Thanks but in the I2C-spec, they do the calculations with VOL and IOL. and not VIL. – Kono May 28 '18 at 15:47
  • ti.com/lit/an/slva689/slva689.pdf – Kono May 28 '18 at 15:47
  • VOL is only quoted at 20mA (I should have used 20mA above not 25, but that's a minor difference). You notice the figure of 0.9 for VOL in the datasheet is the same (near enough) as the final value I calculated above (0.94)...? – Majenko May 28 '18 at 15:51
  • The official datahseet, does the calculation not with RDSON. But just simple by VOL and IOL – Kono May 28 '18 at 15:54
  • All are related. – Majenko May 28 '18 at 15:55

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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