I currently have a RPi 3B communicating very nicely with an Arduino (through a logic level shifter)
I'd like to hook up more Arduinos. I realize this is possible by giving the Arduinos different addresses. But, I'm reading conflicting reports online about internal pullup resistors on the Arduino's I2C pins. It seems that the Pi has 1.8k pullups on the i2c lines, already.
Is anyone familiar with this?
The Arduinos use weak pullups. If you use a I2C compatible logic level converter, you should not have a problem. The one I use (Adafruit) works fine between Arduinos and RPis.
But, I'm reading conflicting reports online about internal pullup resistors on the Arduino's I2C pins.
What is the conflict?
It seems that the Pi has 1.8k pullups on the i2c lines, already.
Indeed it does but that is a pull up to 3V3, if you are going through a logic level shifter you need pull up resistors on each side so you have to add them to the Arduino side to 5V. The internal pull ups are not enough to give you a good shape pulse and while it might appear to work there are problems as this link shows:-
Those were some fast replies.
My level shifter is indeed i2c compatible.
The conflicting reports I've seen seem to be saying either 1) Arduino's built-in ones shouldn't be there, and 2) the Arduino built-in pullups are fine.
Now I'm seeing a third one, where it sounds like you're giving good reason for adding external pullups to 5v for each Arduino's i2c lines.
In the article you linked to, it's referring to the Arduino as the master. So, when it says single-slave, it's referring to the DS3231 IIRC. And they say in single-slave setups, 4.7k pullups on the Arduino work well, but that resistance needs to be lowered for multi-spave setups due to capacitance increases. Is it safe to assume that the slaves in this regard do not have pullup resistors of their own?
Therefore, if so, then on a multi-slave Arduino setup (where the Arduinos are the slaves) should each one have 4.7k resistors regardless of count?
The conflicting reports I've seen seem to be saying either
- Arduino's built-in ones shouldn't be there, and
- the Arduino built-in pullups are fine.
Number 2 is wrong. You can in fact get away with not having a level converter if you disable the internal ones by either hacking the libiary or using a libiary that does not enable them by default and just going with the pull ups on the Pi. The 3V3 signal high is just enough to look like a logic one on a 5V Arduino.
In the article you linked to, it's referring to the Arduino as the master.
There is no difference between a master and a slave in this respect. You only need one set of pull up resistors on a bus, it covers all the master / slaves. A value of 4K7 is fine and I have used that for at least five devices on a 5V I2C bus, on commercial equipment.
With respect to #2:
- the Arduino built-in pullups are fine.
Actually, it depends....
Part of what can make talking about Arduino difficult is the term "Arduino" itself.
It is way too encompassing as it has so many different meanings depending on context.
It can mean, a board, an IDE, a "language", or a processor.
In this case there can be a difference between "Arduino - meaning the board" and "Arduino - meaning the AVR processor".
This is because some arduino boards (like the Arduino Mega boards, have i2c pullups on the board and are not depending on the internal AVR pullups.
So when saying "The Arduino built-in pullups are fine" that is a true statement on the Arduino Mega boards since they have pullups on SDA and SCL signals on the board.
But other AVR based boards do not have pullups on their boards and attempt to use and depend on the weak internal AVR pullup resistors which is not reliable so external pullups really need to be added.
--- bill
Very interesting.
I plan on using 1 Mega 2560, then a couple small devices (Nano, Pro Mini, Pro Micro). It looks like the Mega has 10k i2c pullups on board.
So the currently proposed setup is:
- Pi
- Bi-directional logic level shifter
- Arduino Mega (10k pullup on board)
- Arduino Nano
Since the 10k applies to all, but 4.7k is ideal, would it make sense to add another pair of 10k resistors on the Arduino side of the i2c bus so that the total resistance would decrease to 5k? Is that accurate?
So when saying "The Arduino built-in pullups are fine" that is a true statement on the Arduino Mega boards since they have pullups on SDA and SCL signals on the board.
I would agree with that. Although at 10K it is higher than it should be. But the margin is a lot smaller with 10K. It is a compromise between what is good for the I2C and what is good for the pin when it is in the analogue mode.
Ok, so a Mega 2560 w/ onboard 10k plus a pair of external 10k pullups?
Yes that is what I would do.
And if no Mega (only Arduino boards without onboard pullups), a pair of 4.7k's, correct?
Note for future readers: Not all Megas have the 10k pullup.
I have a four Mega 2560s (from companies other than Arduino). The two that have the 2560 + 16u2 do have the 10k pullups. The two that have the 2560 + CH340g do not have the pullups.
So, use a multimeter and test the resistance between SDA/SCL and 5V before you go counting on those.
(And, Mike, thanks again for the link. It has a very good explanation of this stuff.)