Go Down

Topic: Can you tell me what this means and (Read 1 time) previous topic - next topic

hextejas

Does attaching a slave device to the SDA and SCL ports automatically pull them up ?

raschemmel

#61
Nov 26, 2020, 11:45 pm Last Edit: Nov 27, 2020, 05:17 pm by raschemmel
"Does attaching a slave device to the SDA and SCL ports automatically pull them up ?"

Are I2C internal pullups automatcally enabled ?

LOOKAHEAD_CARRY QUOTE FROM Paul_B:

"Apparently, the "wire" library does so unless modified."

Paul__B

OK, why not, in for a penny, in for a pound!  :smiley-lol:

The vast majority of I2C devices have no pull-up - it is not part of the specification.  The pull-up is provided externally.

It happens however that a microprocessor - such as the ATmega - has both I2C hardware and as an independent feature of the processor, a pull-up function so you can enable the pull-ups in your code.  Apparently, the "wire" library does so unless modified.

However those pull-ups are quite weak, about 47k.  The recommended pull-ups for I2C are more in the range of 4.7k down to perhaps 1k.  You use a lesser value of resistor for longer connecting wires which have more capacitance.  So in general, you want to provide external pull-ups in your design.

Note that resistance value is the total value of any pullups connected anywhere on the same bus in parallel and resistors in parallel reduce the total value.  On a fairly long bus it is desirable to put a pullup at each end so that in parallel the resistance is about that 1 to 4.7k.

Now if you are using pre-made I2C modules such as the "backpack" for a LCD display or a "port expander", this often (if not always) includes pull-up resistors.  If that is the only thing to which you connect your Arduino, that is fine and convenient.  But if you connect - because they are all in parallel - a substantial number of such modules, then the parallel resistance of the pullups may drop very low.  The Arduino (ATmega328) will happily pull down a 330 Ohm load (less than 20 mA) but slave devices also are required to pull the lines down in order to exchange data and they generally have a lesser capability, so you need to keep the total pullup resistance above 1k by removing the pullups on all but a couple of the modules.

The final complication is mixing 5 V and 3.3 V devices (such as the 3.3. V ESPs).  5 V devices will generally operate at 3.3 V so you can connect your pullups to 3.3 V and not 5 V in this situation.  If that does not work, you need to use a particular bi-directional level converter.

Did I miss anything?  :smiley-cool:

raschemmel

#63
Nov 27, 2020, 11:04 am Last Edit: Nov 28, 2020, 06:01 am by raschemmel
"Did I miss anything?"

Yes, the OP is software guy and anything hardware
related is TMI.




Paul__B

"Does attaching a slave device to the SDA and SCL ports automatically pull them up ?"

Are I2C internal pullups automatically enabled ?
Well, strictly separate questions.

Attaching a slave device pulls them up if - and only if - there are pullups on the slave device module.  It has nothing to do with the microcontroller.

The "wire" library chooses to enable the internal pullups which may however in themselves be insufficient,.

hextejas

"Did I miss anything?"

Yes, the OP is software guy and anyhing hardware
related is TMI.

"Without wishing to cause offence, you've been told multiple times how to do this but you keep asking the same question, I am beginning to think you are behaving like a troll"


63 posts to ask about a pullup resistor ?
Really ?


And we're not out of the woods yet...

Raschlamiel, please stay out of my thread. Your snarkieness has gone too far IMO. And I have not been told multiple times how to do this. Or you have tried to tell me in terms that are foreign to me. Or you have answered questions and the answers made no sense. Enough for me.
Yes, 63 posts, because it is not a simple topic when 1st presented to a noob like me. Plus for some reason posters like yourself somehow refuse to answer my easy-to-answer posts:
For example, my post #59
Quote
Quote
Quote
and make sure that SDA is pulled up, and that SCL is also pulled up
I also understand to treat SDA and SCA pull ups differently though how do I wire this pull up ?
My question is "How do I wire this pull up ?
No need to draw a picture, something along the lines of " one end of a 4.7k resistor into the merged SDA leads and the other end into (VCC or +3.3V or 5V). And therein lies a rub. One of my slave boards is at 3.3V and the other is at 5V. Though the Feather Huzzah and ESP32 are at 3.3V. After much tired hammering at this, I have realized that I might need to go somewhere else to try and get help.
As shown by Paul__B, there is more to this than just hooking wires. There are a lot of "ifs" here.
Quote
Attaching a slave device pulls them up if - and only if - there are pullups on the slave device module.  It has nothing to do with the microcontroller.

The "wire" library chooses to enable the internal pullups which may however in themselves be insufficient,.

TheMemberFormerlyKnownAsAWOL

Quote
One of my slave boards is at 3.3V and the other is at 5V. Though the Feather Huzzah and ESP32 are at 3.3V.
So, you need level-shifters.
Please don't PM technical questions - post them on the forum, then everyone benefits/suffers equally

raschemmel

#67
Nov 27, 2020, 05:11 pm Last Edit: Nov 28, 2020, 01:16 pm by raschemmel
That wasn't my quote.
It was from Reply#50.

jpollard

#68
Nov 28, 2020, 12:11 am Last Edit: Nov 28, 2020, 12:16 am by jpollard
No need to draw a picture, something along the lines of " one end of a 4.7k resistor into the merged SDA leads and the other end into (VCC or +3.3V or 5V). And therein lies a rub. One of my slave boards is at 3.3V and the other is at 5V. Though the Feather Huzzah and ESP32 are at 3.3V. After much tired hammering at this, I have realized that I might need to go somewhere else to try and get help.
As shown by Paul__B, there is more to this than just hooking wires. There are a lot of "ifs" here.
You don't want to pull the SDA/SCL lines up to 5V if you have 3.3V devices on the bus, because if their pins are not 5V tolerant you can damage your 3.3V board. As Paul mentioned it is safe to pull the bus up to 3.3V, but this logic level may not be high enough to reliably be interpreted as a high input at your 5V devices. You can try it without breaking anything, if it doesn't work you need to look at voltage level shifting. You can buy premade modules to do this without too much messing around, such as the below module

https://www.sparkfun.com/products/15439

So for your first test, one end of your 4.7k should connect to your SDA lines, the other end should connect to the 3.3V supply. Grab another 4.7k resistor and do the same thing with the SCL lines.

Go Up