Internal pull up resistor in i2c, Arduino uno

Hi
When configuring the Arduino uno digital pins to work as i2c pins, are they automatically configured to use internal pull up pins?
Thanks a lot. :slightly_smiling_face:

The internal pullups are too weak to be used reliably with I2C.

I2C needs somewhere in the range 4k7 to 10k to function at decent speed reliably. The internal pullups are somewhere in the 30k to 50k range.

I can interpret your word "automatically" in different ways :thinking:
They are not accidentally turned on, they are deliberately activated in code.
It happens here: https://github.com/arduino/ArduinoCore-avr/blob/master/libraries/Wire/src/utility/twi.c#L87

  // activate internal pullups for twi.
  digitalWrite(SDA, 1);
  digitalWrite(SCL, 1);

Hi, thanks a lot!!

I appreciate all your help.

Ill connect 4.7kohm resistors to the data and clock.
Should they pull up to 3.3v or 5v in the arduino uno?

They should be pulled up to what ever the processor is being powered by. In the case of a Uno this is normally 5V.

But this also depends on what voltage the slave I2C device is expected which depends on what it is.

Hi Mike
Thanks!
Im working with the Max30101
It says in its datasheet

"The MAX30101 operates on a single 1.8V power supply
and a separate 5.0V power supply for the internal LEDs.
Communication is through a standard I2C-compatible interface"

Im a bit confused what voltage its i2c works with.

Datasheet:
https://www.google.com/url?sa=t&source=web&rct=j&url=https://datasheets.maximintegrated.com/en/ds/MAX30101.pdf&ved=2ahUKEwiC4fTl0IH3AhXuR_EDHZxhBkIQFnoECAwQAQ&usg=AOvVaw3hJBl3sgUMYThj1cZWFvN-

It should work with the I2C lines at 5V; apparently those pins will tolerate up to 6V.

Thanks a lot :slightly_smiling_face:

Internal pull-ups are only active when the IO lines are configured to work as input lines.

In I2C, the SCL line is always output wrt Master, then how are we going to associate internal pull-up with this line?

Nope. You have to specify them in the pinMode function call, if you want them on or off.

When using the I2C lines (both of them) they are set to a special type of output known as an open collector output. They are also automatically set to have their pull up resistors enabled. So if you want that disabled you have to specifically turn off the pullup resistors with a

pinMode(A4, INPUT);
pinMode(A5, INPUT);

immediately after the Wire.begin(); call.

By the "Wire" library code, not the chip itself.

Well I thought the preceding sentence

made it clear.

However to make it ultra clear this setting of the pull up resistors is only done by the default wire library. There are other libraries that allow you to specify if you want them turning on or off.

The sparkfun MAX30101 module includes 2.2kΩ pull-up resistors.

Open drain?

Does it mean that apart from Port-C's own set of pull-up resistors, the I2C Logic also has its own set of 2 pull-up resistors (Fig-1)?

i2logic3
Figure-1:

If there are internal pull-ups for the I2C Logic, then why does the data sheet ask for external pull-up in order to form I2C/TWI bus?

Quote: from Page-260/2016
"The only external hardware needed to implement the bus is a single pull-up resistor for each of the TWI bus lines."

Technically speaking correct, but it is well known that the use of open collector encompasses open drain as the topology of the circuit is the same.

No these pull up resistors are the ones any pin normally has.

Because on this matter the data sheet is incorrect or at least wildly optimistic as to a normal I2C pull-up value used. Any half way decent engineer knows that for 5V you use a 4K7 resistor giving a 1mA pull down current. I suspect the marketing department got in on the act.

Whys are the above when the syntax is as follows:?
digitalWriteX

Maybe better to use

  digitalWrite(SDA, 0);
  digitalWrite(SCL, 0);
// or
  digitalWrite(SDA, LOW);
  digitalWrite(SCL, LOW);

so the code can also be used on other Arduinos.
Leo..

Wasn't me. I was only showing the source code of the Wire library where the internal pullup is enabled.

Yes! The referred Library contains those usages which do not go with the definitions prescribed by Arduino Reference Manual.

Quote from the referred library:

 // activate internal pullups for twi.
  digitalWrite(SDA, 1);
  digitalWrite(SCL, 1);