Pullup resistor on I2C SDA and SCL line is only a positive thing or it can also lead to problems?
I have 4x 3.3v I2C sensors on one ESP32 line and they work without pullup. I can solder 10k resistors but I don't want to end up turning a working system to a troubleshoot weekend.
As far as I know, the ESP32 does not have pullup resistors.
Perhaps your modules with the sensors have pullup resistors ? Can you give a link to where you bought them ?
Yeah, it looks like the adafruit board, and the most common versions of the others all have their own on-board pullups. Worth noting that if you have too much pull-up, that will eventually be a problem when the device's drivers aren't able to overcome the pullups to drive te pins low. (I think you need to get into the low hundreds of ohms net resistance, I think you're still at ~2.5k)
Most DS3231 modules have 4k7. There are MPU9250 modules with level shifters with 2k2 on both sides. The cheap ADS1115 modules that I can find has 10k pullup.
Let's calculate that: 10k // 10k // 4k7 // 2k2 // 2k2 // 10k = 703 Ω, and the sink current will be 4.6mA. That is too much, it should be below 3mA.
When in doubt I read the spec for each device, they are not all the same. The spec states:
SDA and SCL logic levels
Due to the variety of different technology devices (CMOS, NMOS, bipolar) that can be connected to the I2C-bus, the levels of the logical ‘0’ (LOW) and ‘1’ (HIGH) are not fixed and depend on the associated level of VDD. Input reference levels are set as 30 % and 70 % of VDD; VIL is 0.3VDD and VIH is 0.7VDD. See Figure 38, timing diagram. Some legacy device input levels were fixed at VIL = 1.5 V and VIH = 3.0 V, but all new devices require this 30 %/70 % specification. See Section 6 for electrical specifications.
Pull up resistors are required by design. The SDA and SCL are typically driven by either open Drain or Open Collector outputs as the Or function needs to be implemented for it to operate.
I check all the device.
I have 10k on the MPRLS and the ADS1115, 4,7 K on the RTC, 2.2k on the MPU9250.
Doing the math, I find 576 ohm. It is 3.3 volts logic so about 5.7 mA. Or about 4 mA at 70% VIH.
If too much current, what can I do about this? Removing all the onboard pullup and adding external parts?
If too much current, what can I do about this? Removing all the onboard pullup and adding external parts?
Then simply remove the resistors from some of the boards. You should be aiming for 1 to 2 mA current. So only one board needs pullup resistors on them if it is the right value.
Or as you say remove them for all boards and fit them externally.
Can you give links to the modules (links to where you bought them) ?
When the MPU9250 has level shifters, then that level shifter needs pullup resistors on both sides. Preferably 10k on both sides, and the 10k on the I2C bus don't have to be on that module. However, that pullup resistor between the sensor and the level shifter has to be there. You might be stuck with that 2k2, or you have to remove the level shifter itself (the mosfets).
You can actually measure in your project the sink current of SDA and SCL. I gave a link to my page for that.
Everything is on a PCB. Hard for me to measure the sink current. I will have to build the circuit on a breadboard with extra parts
Since I power all the sensors with a regulated 3.3volts, I don't think the pullup on a level shifter will interfere in the setup. There is no 5 volts on any Vin pin.
So I guess the best would be to remove the 2.2K on the ADS1115. Then I have 2.7 mA sink.
I think my guesses for the pullup resistors on the modules are about right.
I don't see the 2k2 on the ADS1115 module, they are on the "MPU9250+BMP280" module.
The MPU9250+BMP280 module called "GY-91" has a level shifter with 2k2 pullup on both sides. There needs to be a pullup resistor between the level shifter and the sensors. If you remove all four, then it might no longer work.
Options:
Keep the two 2k2 pullup between the level shifter and the sensors. Calculate and measure the total sink current.
Replace those two with 10k resistors.
Remove all four pullup resistors and remove the level shifter. Make connections for the SDA and SCL (I think you need a magnifier).
Buy a 3.3V only sensor board without level shifters. Those level shifters make the signals weaker and you don't need them.
The real module is not the same as the schematic, the pullup resistors are not 4k7, but 2k2. There is an extra 2k2 for the led instead of 1k.
Do you have a rechargeable battery with the DS3231 ? Then be sure to power it with 3.3V and not with 5V. You can remove the diode from that module and use a normal battery, or do as I did: put a 5V supercap in the place of the battery
It's easy to verify onboard pullups by measuring the resistance from SCL & SDA to Vcc with the power off
If there is a pullup onboard, it is likely closer to 10k than 4.7k which is a typical value. Either is fine.
I measured the SDA and SCL short to ground current while running the wire library with empty loop as recommended. I obtained 4.7 mA on each bus.
I also measured the resistance of SDA and SCL vs Vcc with power off as @raschemmel suggested.
I obtained 2.1 k.
Both method do not exactly match. Based on the resistance value, I should read a current of 3.3v / 2.1 k = 1.6 mA. And 1.6mA is in the good range. But 4.7mA (short to ground method) is too much.
In the actual condition (no modifications), my setup work. What is the risk of overlooking the pull-up value? The board will failed over time? Communication will become intermittent? When battery will sag, the problem will become more important? It become a cost / benefit issu.
cdb101:
What is the risk of overlooking the pull-up value?
That depends on the manufacturer of the chip. Every I2C device is allowed to sink more current, but it should at least be able to sink 3mA for a low signal.
The 4.7mA is close to 3mA, so that might be okay, but your signal/noise distance is worse.
To be sure, you would have to measure the 'low' level voltage for every I2C device with a scope.
The sink current should be calculated, grounding the pins can damage the ICs. The sink current on the specification is a MAXIMUM not a required level. The bus capacitance etc all have an effect on it. You can check it by measuring the rise and fall times with a scope and a low cap probe.
Hello,
I finally have instability with my setup and it become anoying when I connect the MPU board. I make a mistake somewhere.
Remember I use a ESP32 (so 3.3v power and I2C logic)
I assume that wiring my 3.3volts PSU on the 3.3v pin of the Gy-91 board would give me a good I2C setup at 3.3v but relooking the above schematic, I think this is wrong since H_SCL and H_SDA line hard wired to my ESP are in reality connected to the VCC_5v pullup not the 3.3v pullup.
Do you think I can do any of the two following option:
1- solder 3.3v and VCC together. If so will this interfere with the n-mos shifter?
or
2- connect my 3.3v to VCC_5v and assume that the LDO will output the required 3.3volt on the other side to power the sensors? ... I don't have 5volts available on my system and don't plan to add a PSU just for that.