Go Down

Topic: How to figure out what size pull-up resistor needed for I2C connection? (Read 169 times) previous topic - next topic

jbc165

Hi all:

I'm new to dealing with electronics/hardware, and have an interest in building some meteorological stations that record temperature/humidty/moisture with a time stamp, each of the sensors run using I2C protocol. I've built these before with an EnviroDIY Mayfly datalogger. However this microcontroller had an I2C plug so it was pretty easy to wire my sensors together and plug into the provided I2C connector.

Now I've learned I can reduce the cost of the stations substantially by building just the individual components I need using a 3.3V Arduino Pro Mini build, so I'm exploring that. I know that in order to run I2C off this microcontroller, I'll need to use pull-up resistors on the SDA and SCL lines, but I don't really know enough about electronics to know what size resistor is needed. I'd like to know what size resistors are needed on the SDA and SCL lines, but I also would like some help generally understanding how to figure this out on my own in the future. I've seen some datasheets, but I don't really know what values I'm looking for (average current consumption? idle current consumption?). And when I have these values I'm not so sure what to do with them.. So I'll list my setup as well.


Here is my setup, I plan on connecting 3 devices to the I2C bus
  • Microcontroller: 3.3V Arduino Pro Mini (knockoff)
  • Connected to a solar/lithium battery charger module

The I2C devices that will be connected include:

If it matters, I also plan to connect this SPI SD card reader (But I haven't really looked into how to do that yet).

Any guidance on how to find these data sheets, what values to look for and how to calculate what size resistor is needed would be helpful! Thanks


pwillard

I2C generally expects the pullups to be about 1ma in strength.  (Like highlander, there can be only 1, so if your cards have built in pullups, disable them and install 1 set on the bus signals)

This means the ideal starting value for pullups on the 3V Nano would be 3300 ohms or 3.3K. Ohms.

If your wires start getting long... drop down to 2.2K

jbc165

Thanks for the information. This raises two more questions

  • How long is a "long" wire? The RTC will be right next to the microcontroller (< 5 cm), the temperature and moisture sensors will each be about 1 m away. Is that getting long enough to matter?
  • How can I look at the datasheets and tell if there is already a pullup resistor? If so, how do I disable it? Adding a jumper or severing a connection? Not sure if I'm brave enough for either of those

wvmarle

1 meter is quite long for I2C already.

It's no problem to have multiple weaker pull-ups spread around your I2C bus. Maybe even better than a single equivalent one. Sensors normally have no pull-ups on board; sensors on breakout boards usually have 10k pull-ups.
Quality of answers is related to the quality of questions. Good questions will get good answers. Useless answers are a sign of a poor question.

ChrisTenone

Thanks for the information. This raises two more questions

  • How long is a "long" wire? The RTC will be right next to the microcontroller (< 5 cm), the temperature and moisture sensors will each be about 1 m away. Is that getting long enough to matter?
  • How can I look at the datasheets and tell if there is already a pullup resistor? If so, how do I disable it? Adding a jumper or severing a connection? Not sure if I'm brave enough for either of those

The data sheets are for the ic devices, not the breakout boards, so they wouldn't tell you if the boards had resistors. However, the web page for the moisture sensor says "Don't forget to provide pullups for SCL and SDA lines", so no, it does not have them. Looking close up at the RTC board, it has 2 resistors. These are marked 201 and 102. The first being 200 ohms, and the latter is 1000 ohms. Neither is likely to be a pullup resistor, and besides, it would be two of them the same.

The temperature sensor however has two 103 (10K) resistors right next to the SDA and SCL pinouts. So bingo, that sensor has pullup resistors. Since you have (very) long wires, you are going to want to pull it up even more than 10K though. Add a pair of 4.7K resistors to the system to get 3300 total ohms of pullup.
I don't got to show you no stinkin' signature.

Koepel

There is a schematic of that RTC module. It has 4k7 for SDA and SCL.

So far: Pro Mini = internal 50k pullup, RTC = 4k7, SHT-31D = 10k.
50k // 4k7 // 10k = 3k (you can check my calculation).
That makes 3.3 / 3k = 1 mA

The I2C bus is specified as 3 mA.
Every device should be able to sink at least 3 mA (more is allowed). That means that if a manufacturer makes a sensor that can sink 3 mA, it is already according to the I2C specifications.
Because of that, the maximum sink current for the I2C bus is 3 mA (even though each device is allowed to be able to sink more current).

When you have 1 meter to a sensor and 1 meter to another sensor, you I2C bus is 2 meters long.

The rule of thumb is maximum of 0.5 meters. But that depends on the used cable. A very bad cable might not even get to 0.5 meters and a very good cable (little capacitance to ground, no crosstalk between SDA and SCL) can go up to 6 meters. But don't try 6 meters, that is silly. The best cable is no cable at all, just a bunch of individual wires that are not near other wires is the best.

I'm a little worried about the power voltage. Do you use the onboard voltage regulator of the Pro Mini board to get 3.3V for the SD card ?
Some newer Arduino board have a battery connector. For example the MKR1000.

ChrisTenone

There is a schematic of that RTC module. It has 4k7 for SDA and SCL.
...
Oh yeah, I see 'em, long parts, marked 472. Maybe just hook it up and see if it works then.

I don't got to show you no stinkin' signature.

Go Up