Measuring Existing I2C Pullup resistance on a sensor

I was wondering if anyone knows the correct way to measure the existing value of a sensor's pullup resistance. I have an existing I2C ToF distance sensor which is sealed in a casing which has four wires (Vcc, Gnd, SDA & SCL) . Is it as simple as measuring the SDA and SCL lines against the ground or is there more to it?

Thanks,

well, a pullup would connect from signal to VCC, so that's worth a try, not ground.
But, it's very likely to not yield useful info. Why? Because I wouldn't expect the instrument to have a built in pullup. Doing that means that every sensor adds a pullup, and that quickly begins to load the signals unacceptably. So if there IS a measurable resistance, say 4.7k ohm, then your device is limiting the number of other devices you can add to your I2C bus, which shouldn't be the case. I'm hoping you'll read a very high resistance, which will mean that you, as the system designer, have the freedom to add your pullup where YOU want to.

1 Like

One safe way is reading the documentation, datasheet for the device.

1 Like

No because these are pull up resistors not pull down resistors.

Take a resistance reading between the + voltage line and each of the resistors in turn. They should be the same and about 10K.

I would disagree. These sensor boards are not designed for a professional user. These things a purely hobby stuff. Why else would you sell a board with the actual chip on it and then encapsulate it. If the sensor only has one I2C address then you are not going to use more than one module on the same bus anyway are you?

I2C is a bus. If the hobby market abuses it, do I care? Not at all. What should be, often isn't. Plenty examples of that, here and elsewhere. Over to you, I'm done.

You cannot measure with MCU itself, if there is a pull-up in I2C (needed!) or not.
But you can probe with an oscilloscope.
Or:
power up the MCU, do not do anything, measure the voltage of SDA and SCL signal pins.
If you see a stable 3V3 - it tells you: there is a pull-up (but not its resistance, "strength").

The MCU does not have any clue. It will just fail if no pull-up is there (or a wrong value for resistance, for instance: faster speed needs stronger pull-ups, lower resistance).

If you are not sure if pull-up is there or not: you could enable internal MCU GPIO pin pull-up. This should result in a proper 3V3 level when not in use. But this pull-up might be two weak for operation (often 10K internal MCU pull-up but way too large, e.g. for 100 KHz often 2K2 used).
But when you see now, instead of a floating signal - there is now a stable 3V3 on SDA and SCL - it tells you: there are NO pull-ups outside.

Even you have pull-ups, but you want to know if it the right value (or which value):

  • take a 1K resistor, an amp-meter, but in series and measure the current (assuming you know it comes from 3V3 supply): now you can calculate the resistance of the pull-up
  • better: use an oscilloscope and see the waveform:
    a weak pull-up (large resistance) limits the speed possible for I2C: if you see curving signals,
    like arcs on the rectangle signal - the resistance is too large (too weak pull-up),
    faster speed needs lower resistance so that the round signal edges disappear

A scope or voltmeter will tell you (if you have pull-ups, and also the right value), but not the MCU.

I2C specifies an acceptable (max.) current of 3 mA, not a resistance. Connect and power all devices connected to the bus and measure the short circuit current from SCL and SDA to GND. If it exceeds 3 mA then some pullup resistors have to be removed.

1 Like

@Grumpy_Mike But you are right, in a sense. Just like most of the el cheapie MAX485 adapter boards have the 120 ohm resistor installed A-B, resulting in bus overload if more than a few are attached. User beware, I guess. Typical newbie trap.

Hi, @arduinoguy007
Welcome to the forum.

What is the part number of the ToF?

Thanks.. Tom.... :smiley: :+1: :coffee: :australia:

Simple:

  • you'll need a spare resistor (any value from 1K to 10K) and a multimeter
  • with the sensor powered, connect the resistor from SDA to GND
  • measure the DC voltage on SDA

Using this on-line calculator
image

  • Select units (kΩ)
  • Enter VCC in the source voltage box
  • Enter SDA voltage in the output voltage box
  • Enter the resistor value in the resistance 2 box
  • Press Calculate ... the sensor's SDA pullup resistance will be revealed in the resistance 1 box

Repeat this procedure for SCL.

1 Like

You can get an approximation by using a pull down resistor, maybe in the 2K range to start. Power it up then measure the voltage from ground to SCL and SDA, when you get a useful reading you can use Ohm's law to calculate the resistance. Both are open drain or open collector so if not asserted you should come out reasonable close. What you are doing is forming a voltage divider and your resistor is the lower one, the pull up will be the sum of all of the pull up resistors on each lead.

Remember you have to execute the Wire.begin() method before the I2C pins will turn into open drain pins. Before that they are just normal pins that will default to input on reset or power up.

I would connect only power/ground to the sensor.
First measure voltage on the I2C pins, to see if it's internals work with 3.3volt or 5volt-logic.
Then measure current between SCL and ground, repeat for SDA and ground.
Now you know logic voltage and pull up current.
Working out pull up resistance is a matter of using ohms law.
Leo..

There is no different behavior between open drain (off) and input (high Z) pins. They do not contribute to nor consume pullup current, that's the sole task of external pullup resistors.

My advice is to use a empty sketch with Wire.begin() and measure the short circuit current from SDA to GND and from SCL to GND.

The Wire.begin() often enables the internal pullup resistors.

OP only asked for the sensor's internal pull up.
Leo..

And we haven't got a part number yet.

Tom... :+1: :smiley: :coffee: :australia:

Thanks for all the feedback. I finally decided to bust open the custom box the ToF sensor was enclosed in to find a terabee evo-mini I2C ToF sensor. I was able to confirm that the sensor does indeed have a 10K pullup on SDA/SCL as per the manual (page 25) evo_mini_manual . I'm using this with a Mega which also has permanent 10K pullups, so I'm thinking of de-soldering the pullup on the mega board since there is no way to remove them using code (there soldered in...). I'm using this sensor as it's much more accurate for reading unlevel surfaces (such as grain containers). It uses 3.3v logic, but I'm using a level shifter to make it work with the mega's 5 volts... Thanks again for all the help...

Absolute no need to remove anything, two 10K resistors in parallel still means in effect a 5K pull-up resistor.

The level shifter has 10k on both sides.

Your total sink current with the Arduino Mega and the sensor is:
5/50k + 5/10k + 5/10k + 3.3/10k + 3.3/10k = 1.76mA
It can be up to 3mA.

Unless there are other things connected to the I2C bus.