I've been looking around the internet, and I've seen some i2c diagrams use 2 10k resistors to pull up the SDL and SDA lines to Vcc.
I've done some prototyping with i2c, but never installed these resistors, and never had any problems. But I'm looking at taking one of my creations to a full time, in use, circuit. Soldered and everything.
Before I do that, I'd like to make sure I get everything right. So, are they necessary?
Thanks
Rick
-
- Posts: 430
- Joined: Thu Aug 02, 2012 12:21 pm
- Location: Buffalo, NY, USA
Does i2c need pullups (resistors, not diapers!)
There are 10 types of people in this world. Those that understand binary, and those that don't.
Re: Does i2c need pullups (resistors, not diapers!)
I believe the answer to be yes, the resistors are necessary. The Pi's SDA and SCL lines have physical resistors on the board to pull up to 3.3V.
-
- Posts: 430
- Joined: Thu Aug 02, 2012 12:21 pm
- Location: Buffalo, NY, USA
Re: Does i2c need pullups (resistors, not diapers!)
That would explain why I haven't needed them. I've only done I2C from the RPi, and they are already there.joan wrote:I believe the answer to be yes, the resistors are necessary. The Pi's SDA and SCL lines have physical resistors on the board to pull up to 3.3V.
Thanks!
There are 10 types of people in this world. Those that understand binary, and those that don't.
- Richard-TX
- Posts: 1549
- Joined: Tue May 28, 2013 3:24 pm
- Location: North Texas
Re: Does i2c need pullups (resistors, not diapers!)
rickseiden wrote:That would explain why I haven't needed them. I've only done I2C from the RPi, and they are already there.joan wrote:I believe the answer to be yes, the resistors are necessary. The Pi's SDA and SCL lines have physical resistors on the board to pull up to 3.3V.
Thanks!
While you don't necessarily need 10k pullups, if you expect to have cable length of any distance, each chip should have it's own pullups. Want to have 10 ft or more of cable? Use CAT6 network cable and assign the signals as follows: I have driven the I2C bus to I2C Plus speeds without issue provided each chip has it's own pullups and 568B patch cables are used.
Here is an example of what can be done using RJ45 connectors.

right click and "view image" for larger picture.
Richard
Doing Unix since 1985.
The 9-25-2013 image of Wheezy can be found at:
http://downloads.raspberrypi.org/raspbian/images/raspbian-2013-09-27/2013-09-25-wheezy-raspbian.zip
Doing Unix since 1985.
The 9-25-2013 image of Wheezy can be found at:
http://downloads.raspberrypi.org/raspbian/images/raspbian-2013-09-27/2013-09-25-wheezy-raspbian.zip
-
- Posts: 430
- Joined: Thu Aug 02, 2012 12:21 pm
- Location: Buffalo, NY, USA
Re: Does i2c need pullups (resistors, not diapers!)
The distance I'm covering is inches, if that much. I just did some work with my GertBoard and I2C, and forgot to put the pull-up resistors in place. It worked just fine. Now I'm more confused then ever!
There are 10 types of people in this world. Those that understand binary, and those that don't.
- Gert van Loo
- Posts: 2487
- Joined: Tue Aug 02, 2011 7:27 am
Re: Does i2c need pullups (resistors, not diapers!)
An I2C interface MUST have pull-up resistors. The value of those depend on the voltage and the speed you plan to run at.
The Raspberry-Pi already has pull-up resistor on the board so you don't have to add any more.
That is if you connect to the Pi!
But!! If you ever make your own I2C bus you must add pull-up resistors.
e.g. from the Atmega on the Gertboard to a I2c device other then the Pi.
Note that some controllers have internal pull-up resistors on the I/O pins which you can program to be on.
Those are not suited to be used as I2C pull up resistors as they are often too weak.
The Raspberry-Pi already has pull-up resistor on the board so you don't have to add any more.
That is if you connect to the Pi!
But!! If you ever make your own I2C bus you must add pull-up resistors.
e.g. from the Atmega on the Gertboard to a I2c device other then the Pi.
Note that some controllers have internal pull-up resistors on the I/O pins which you can program to be on.
Those are not suited to be used as I2C pull up resistors as they are often too weak.
-
- Posts: 430
- Joined: Thu Aug 02, 2012 12:21 pm
- Location: Buffalo, NY, USA
Re: Does i2c need pullups (resistors, not diapers!)
Gert, I'm humbled that you weighed in on this! My design right now is from the ATMega 328P on my GertBoard to an MCP23017. I plan on eventually replacing the ATMega with an ATTiny85, if I can. I plan on running the circuit at 5V. How would I calculate the correct resistance on those pull-ups?Gert van Loo wrote:An I2C interface MUST have pull-up resistors. The value of those depend on the voltage and the speed you plan to run at.
The Raspberry-Pi already has pull-up resistor on the board so you don't have to add any more.
That is if you connect to the Pi!
But!! If you ever make your own I2C bus you must add pull-up resistors.
e.g. from the Atmega on the Gertboard to a I2c device other then the Pi.
Note that some controllers have internal pull-up resistors on the I/O pins which you can program to be on.
Those are not suited to be used as I2C pull up resistors as they are often too weak.
Thanks,
Rick
There are 10 types of people in this world. Those that understand binary, and those that don't.
- Richard-TX
- Posts: 1549
- Joined: Tue May 28, 2013 3:24 pm
- Location: North Texas
Re: Does i2c need pullups (resistors, not diapers!)
Just put 10 k resistors between SDA and SCL and VDD with every chip you add to the bus.
Richard
Doing Unix since 1985.
The 9-25-2013 image of Wheezy can be found at:
http://downloads.raspberrypi.org/raspbian/images/raspbian-2013-09-27/2013-09-25-wheezy-raspbian.zip
Doing Unix since 1985.
The 9-25-2013 image of Wheezy can be found at:
http://downloads.raspberrypi.org/raspbian/images/raspbian-2013-09-27/2013-09-25-wheezy-raspbian.zip
-
- Posts: 430
- Joined: Thu Aug 02, 2012 12:21 pm
- Location: Buffalo, NY, USA
Re: Does i2c need pullups (resistors, not diapers!)
I was reading the data sheet on the MCP23017, which I don't fully understand, and trying to compute the pull up value based on this. I came up with the notion that the pull ups had to be greater than 900 ohms, and less then 885 ohms. Obviously, I did something wrong. But I noticed that the data sheet calls specifically for a pull up of 1k ohm, and a capacitor connected between SDA/SDL and ground of 135pF.
So now I need pull up resistors, and "pull down capacitors"?
So now I need pull up resistors, and "pull down capacitors"?
There are 10 types of people in this world. Those that understand binary, and those that don't.
- mahjongg
- Forum Moderator
- Posts: 14923
- Joined: Sun Mar 11, 2012 12:19 am
- Location: South Holland, The Netherlands
Re: Does i2c need pullups (resistors, not diapers!)
Does not compute!the pull ups had to be greater than 900 ohms, and less then 885 ohms.
No value is >900 and <885
The reverse would be possible >885 and <900, but even in that sense, you are talking about a ridiculously precise resistance value. no need for that at all!
The PI's pull-up's are 1800 Ohm, and that is about optimal, its the "strongest" pull-up the PI can still reliably pull down with normal driver strength settings (1.8333 mA) Its possible to use stronger pullups, but normally that isn't needed. If there are still problems with these pullups, then the problem isn't the pullups, but in all probability pulling up to 3,3V doesn't fulfill some minimal logic high level demand somewhere, or there is a problem with clock stretching.
capacitors are not needed or wanted to add, what is probably meant is the maximum parachutic capacitance the wiring may have.
You looking far too deep into this, the pullups are ideal, and are most probably not the culprit.
But simply forgetting the pullups, and having it "work" because GPIO's often have weak pullups (around 50K) -that- is sometimes a problem, the exact value of the pullups almost never is, unless you are talking about optimalisation needed because of very long wiring.
-
- Posts: 430
- Joined: Thu Aug 02, 2012 12:21 pm
- Location: Buffalo, NY, USA
Re: Does i2c need pullups (resistors, not diapers!)
[/quote]mahjongg wrote:Does not compute!the pull ups had to be greater than 900 ohms, and less then 885 ohms.
No value is >900 and <885
My point exactly!
I'm looking to take the circuit off the RPi eventually (it's actually on the AVR on the GertBoard right now, so technically it is already off the RPi). That's why I need to compute the values of these things.mahjongg wrote:The PI's pull-up's are 1800 Ohm, and that is about optimal, its the "strongest" pull-up the PI can still reliably pull down with normal driver strength settings (1.8333 mA) Its possible to use stronger pullups, but normally that isn't needed. If there are still problems with these pullups, then the problem isn't the pullups, but in all probability pulling up to 3,3V doesn't fulfill some minimal logic high level demand somewhere, or there is a problem with clock stretching.
As an aside, I just read at Adafruit that you can power the MCP23017 with 5V, and still hook it up to the 3v3 i2c lines of the RPi because of the internal pull-up resistors. As I only have one RPi, I'm not going to try this any time soon.
There are 10 types of people in this world. Those that understand binary, and those that don't.
- mahjongg
- Forum Moderator
- Posts: 14923
- Joined: Sun Mar 11, 2012 12:19 am
- Location: South Holland, The Netherlands
Re: Does i2c need pullups (resistors, not diapers!)
No, you normally do not need to compute the value of these pullups, just use a value around 2K2, (1K to 10K) and it should work fine, provided that all devices use the same kind of ViH and ViL levels, which is normally the case when they use the same VCC voltage, but NOT if one uses 3V3 and the other 5V! In that case the only generic solution is using level shifters. Tweaking the pull-up value does almost nothing to remedy that problem.That's why I need to compute the values of these things.
- Richard-TX
- Posts: 1549
- Joined: Tue May 28, 2013 3:24 pm
- Location: North Texas
Re: Does i2c need pullups (resistors, not diapers!)
Take a look at what Adafruit does with their 16 port i2c based led/servo controller.
Another way to look at it is that if Adafruit uses 10k ohm resistors and 32 of their devices can be placed on a I2C bus, then 10k must be about right.

right click and "view image" for full size
Another way to look at it is that if Adafruit uses 10k ohm resistors and 32 of their devices can be placed on a I2C bus, then 10k must be about right.
right click and "view image" for full size
Richard
Doing Unix since 1985.
The 9-25-2013 image of Wheezy can be found at:
http://downloads.raspberrypi.org/raspbian/images/raspbian-2013-09-27/2013-09-25-wheezy-raspbian.zip
Doing Unix since 1985.
The 9-25-2013 image of Wheezy can be found at:
http://downloads.raspberrypi.org/raspbian/images/raspbian-2013-09-27/2013-09-25-wheezy-raspbian.zip
- Gert van Loo
- Posts: 2487
- Joined: Tue Aug 02, 2011 7:27 am
Re: Does i2c need pullups (resistors, not diapers!)
My estimate is that 10K is too high for a 400KHz I2C bus.
I use ~2K for 3V3 and ~3K for 5V.
I use ~2K for 3V3 and ~3K for 5V.
- FTrevorGowen
- Forum Moderator
- Posts: 7158
- Joined: Mon Mar 04, 2013 6:12 pm
- Location: Bristol, U.K.
Re: Does i2c need pullups (resistors, not diapers!)
As a (further) aside, my first I2C test circuits were based upon Ciseco's "Slice of PI/O" board (based upon Nathan Chantrell's project)** using an MCP23017 powered by 5V to drive a LED bargraph display or an ex-Sinclair Cambridge calculator display*** w/o problems (and Nathan links to an explanation of why it's O.K. to do this, IIRC).rickseiden wrote: ...
As an aside, I just read at Adafruit that you can power the MCP23017 with 5V, and still hook it up to the 3v3 i2c lines of the RPi because of the internal pull-up resistors. As I only have one RPi, I'm not going to try this any time soon.
Trev.
** http://shop.ciseco.co.uk/k002-slice-of-pi-o/
*** http://www.cpmspectrepi.webspace.virgin ... OfPio.html
Begining to test Bullseye on some older Pi's (an A, B1, 2xB2, B+, P2B, 3xP0, P0W, 2xP3A+, P3B, B+, and a A+) and Pi's with cameras with Buster on the P3B+, some P4B's & P400. See: https://www.cpmspectrepi.uk/raspberry_pi/raspiidx.htm
-
- Posts: 430
- Joined: Thu Aug 02, 2012 12:21 pm
- Location: Buffalo, NY, USA
Re: Does i2c need pullups (resistors, not diapers!)
Trev, You're the second person who's said that it will work. I think that I've had two or three people tell me not to do it under any circumstances, too. I want a bidirectional level shifter, and will be picking one up from Adafruit eventually. Until then, I'm not gonna take the chance. Success stories and all. I'm just to a-scared!FTrevorGowen wrote:As a (further) aside, my first I2C test circuits were based upon Ciseco's "Slice of PI/O" board (based upon Nathan Chantrell's project)** using an MCP23017 powered by 5V to drive a LED bargraph display or an ex-Sinclair Cambridge calculator display*** w/o problems (and Nathan links to an explanation of why it's O.K. to do this, IIRC).rickseiden wrote: ...
As an aside, I just read at Adafruit that you can power the MCP23017 with 5V, and still hook it up to the 3v3 i2c lines of the RPi because of the internal pull-up resistors. As I only have one RPi, I'm not going to try this any time soon.
Trev.
There are 10 types of people in this world. Those that understand binary, and those that don't.
Re: Does i2c need pullups (resistors, not diapers!)
Not knowing any better, I trusted LadyAda on this one, and did this exactly on several circuits. No smoke yet. I believe this is how her 16x2 LCD Pi plate is wired, and there's lots of those out there.rickseiden wrote:As an aside, I just read at Adafruit that you can power the MCP23017 with 5V, and still hook it up to the 3v3 i2c lines of the RPi because of the internal pull-up resistors. As I only have one RPi, I'm not going to try this any time soon.
Last edited by Douglas6 on Mon Dec 30, 2013 7:26 pm, edited 1 time in total.
- Richard-TX
- Posts: 1549
- Joined: Tue May 28, 2013 3:24 pm
- Location: North Texas
Re: Does i2c need pullups (resistors, not diapers!)
I have used 10k with the Rpi I2c bus at 1 Mhz speeds (Fast Mode +) with no issues.Gert van Loo wrote:My estimate is that 10K is too high for a 400KHz I2C bus.
I use ~2K for 3V3 and ~3K for 5V.
Cables have to be Cat5/6, the SDA and SCL signals have to be a twisted pair with ground but other than that no special considerations are warranted. See picture below for one example. I chose this scheme as nothing will get blown up if the wiring is reversed. It won't work if reversed, but nothing will get damaged.
http://www.nxp.com/documents/leaflet/75015806.pdf
Richard
Doing Unix since 1985.
The 9-25-2013 image of Wheezy can be found at:
http://downloads.raspberrypi.org/raspbian/images/raspbian-2013-09-27/2013-09-25-wheezy-raspbian.zip
Doing Unix since 1985.
The 9-25-2013 image of Wheezy can be found at:
http://downloads.raspberrypi.org/raspbian/images/raspbian-2013-09-27/2013-09-25-wheezy-raspbian.zip
- mahjongg
- Forum Moderator
- Posts: 14923
- Joined: Sun Mar 11, 2012 12:19 am
- Location: South Holland, The Netherlands
Re: Does i2c need pullups (resistors, not diapers!)
most of the issues occur when the I2C device expects a logic high that is higher than 3.3V. For example many 5V logic devices expect a minimum high level of 70% of their VCC, that is for a 5V powered device 5.0 * 0.7 = 3.5V.
-
- Posts: 430
- Joined: Thu Aug 02, 2012 12:21 pm
- Location: Buffalo, NY, USA
Re: Does i2c need pullups (resistors, not diapers!)
Does that mean that no harm will come to the RPi if I hook up an I2C device powered at 5V to the I2C on my RPi, and that it potentially just won't work? Or is my RPi at risk doing this?mahjongg wrote:most of the issues occur when the I2C device expects a logic high that is higher than 3.3V. For example many 5V logic devices expect a minimum high level of 70% of their VCC, that is for a 5V powered device 5.0 * 0.7 = 3.5V.
There are 10 types of people in this world. Those that understand binary, and those that don't.
- Richard-TX
- Posts: 1549
- Joined: Tue May 28, 2013 3:24 pm
- Location: North Texas
Re: Does i2c need pullups (resistors, not diapers!)
When dealing with I2c devices it is indeed important to make sure that the specs of the device are adhered to. Some devices want a VDD of 5 volts, others like the PCA9685 will take anything from 2.3 to 5.5 volts, etc.
In the case of the PCA9544 mux, different buses with different voltages can be mixed.
Having said all that all of the I2c chips I have checks use a absolute value of 0.2 volts or lower to indicate a logic low on the I2c bus. I have never seen it be a percentage but I lead a sheltered life.
In the case of the PCA9544 mux, different buses with different voltages can be mixed.
Having said all that all of the I2c chips I have checks use a absolute value of 0.2 volts or lower to indicate a logic low on the I2c bus. I have never seen it be a percentage but I lead a sheltered life.

Richard
Doing Unix since 1985.
The 9-25-2013 image of Wheezy can be found at:
http://downloads.raspberrypi.org/raspbian/images/raspbian-2013-09-27/2013-09-25-wheezy-raspbian.zip
Doing Unix since 1985.
The 9-25-2013 image of Wheezy can be found at:
http://downloads.raspberrypi.org/raspbian/images/raspbian-2013-09-27/2013-09-25-wheezy-raspbian.zip
- FTrevorGowen
- Forum Moderator
- Posts: 7158
- Joined: Mon Mar 04, 2013 6:12 pm
- Location: Bristol, U.K.
Re: Does i2c need pullups (resistors, not diapers!)
Hi again, Rick - for reference here's the link to Nathan Chantrell's discussion of "why it's O.K. (for the Pi)":rickseiden wrote:Does that mean that no harm will come to the RPi if I hook up an I2C device powered at 5V to the I2C on my RPi, and that it potentially just won't work? Or is my RPi at risk doing this?mahjongg wrote:most of the issues occur when the I2C device expects a logic high that is higher than 3.3V. For example many 5V logic devices expect a minimum high level of 70% of their VCC, that is for a 5V powered device 5.0 * 0.7 = 3.5V.
http://nathan.chantrell.net/20120610/ra ... t-voltage/
In essence it's because the I2C buses are [should be] open-drain based. Having used the (loosely) equivalent "open-collector" methods many-many-moons ago I'm fairly confident that one, closely-connected device is fine, but, as Nathan also suggests, I have used (adafruit's "i2c safe") bi-directional level-shifters on circuits using more than one I2C device (eg: http://www.cpmspectrepi.webspace.virgin ... blePi.html and
http://www.cpmspectrepi.webspace.virgin ... oFull.html )
Trev.
Edit: Link corrected (or make sure you pasted what you thought you had

Begining to test Bullseye on some older Pi's (an A, B1, 2xB2, B+, P2B, 3xP0, P0W, 2xP3A+, P3B, B+, and a A+) and Pi's with cameras with Buster on the P3B+, some P4B's & P400. See: https://www.cpmspectrepi.uk/raspberry_pi/raspiidx.htm
- mahjongg
- Forum Moderator
- Posts: 14923
- Joined: Sun Mar 11, 2012 12:19 am
- Location: South Holland, The Netherlands
Re: Does i2c need pullups (resistors, not diapers!)
As long as you only use pullups to 3V3 no harm will come to the PI, but some devices demand a pullup to 5V. That's where levels shifters come in, to split the I2C bus into a 3V3 and a 5V part!rickseiden wrote:Does that mean that no harm will come to the RPi if I hook up an I2C device powered at 5V to the I2C on my RPi, and that it potentially just won't work? Or is my RPi at risk doing this?mahjongg wrote:most of the issues occur when the I2C device expects a logic high that is higher than 3.3V. For example many 5V logic devices expect a minimum high level of 70% of their VCC, that is for a 5V powered device 5.0 * 0.7 = 3.5V.
- Richard-TX
- Posts: 1549
- Joined: Tue May 28, 2013 3:24 pm
- Location: North Texas
Re: Does i2c need pullups (resistors, not diapers!)
Agreed and good advice. Know what you are doing when playing with +5 volts.
Richard
Doing Unix since 1985.
The 9-25-2013 image of Wheezy can be found at:
http://downloads.raspberrypi.org/raspbian/images/raspbian-2013-09-27/2013-09-25-wheezy-raspbian.zip
Doing Unix since 1985.
The 9-25-2013 image of Wheezy can be found at:
http://downloads.raspberrypi.org/raspbian/images/raspbian-2013-09-27/2013-09-25-wheezy-raspbian.zip
Re: Does i2c need pullups (resistors, not diapers!)
Hello.mahjongg wrote:As long as you only use pullups to 3V3 no harm will come to the PI, but some devices demand a pullup to 5V. That's where levels shifters come in, to split the I2C bus into a 3V3 and a 5V part!rickseiden wrote:Does that mean that no harm will come to the RPi if I hook up an I2C device powered at 5V to the I2C on my RPi, and that it potentially just won't work? Or is my RPi at risk doing this?mahjongg wrote:most of the issues occur when the I2C device expects a logic high that is higher than 3.3V. For example many 5V logic devices expect a minimum high level of 70% of their VCC, that is for a 5V powered device 5.0 * 0.7 = 3.5V.
I'm trying to understand which is the correct wiring for a 16x2 and a 20x4 LCD screens I have.
How can I check if I'm in the right situation and I'm not risking to damage the RPi, with reference to the above post?
I added some more info on this LCD here:
viewtopic.php?p=1035575#p1035575
Thanks.
One of my projects with the Raspberry Pi:
--------------------------------------------------------
(Raspberry) Pi Aquarium Controller: https://github.com/dentex/piac
--------------------------------------------------------
(Raspberry) Pi Aquarium Controller: https://github.com/dentex/piac