pull-up resistors value for DS3231S - Page 1
Forum section: electronics / beginners

author: GG
author_rank: Contributor
timestamp: January 06, 2025, 12:42:09 am
content: Dear EEVblog,I am trying to figure out the best value for the i2c pull-up resistors between a DS3231S and a Teensy 4.1.I've read about some designs using 4.7k and others using 10k resistors.Plus over the past days I have read multiple articles and calculators but I'm just getting more confused.Any help or adivice would be greatly appreciated.

author: ahsrabrifat
author_rank: Regular Contributor
timestamp: January 06, 2025, 11:37:22 am
content: 4.7 k ohm should work. You can start with this value and see if you are getting the desired output.

author: Nominal Animal
author_rank: Super Contributor
timestamp: January 06, 2025, 12:03:50 pm
content: Thedatasheet (PDF)defines \$R_{PU} = t_R / C_B\$ in the typical operating circuit diagram on the first page, with page 4 stating \$t_R \le 1 \text{ µs}\$ and \$C_B \le 400 \text{ pF}\$. This calculates to \$R_{PU} = 2500 \text{ Ω}\$. Thus, I would suggest using 2.2 kΩ pull-up resistors.In general, at 3.3V logic (as used with e.g. Teensy 4.1), 2.2 kΩ I²C pull-ups seem to be quite common. It means that to pull the SDA or SCL line down, the current over the switching transistor is 3.3V/2200Ω = 1.5mA, which is quite reasonable for most use cases. (At 4.7kΩ, the current is less than half that, about 0.7mA. At 5V logic –– which Teensy 4.1 pins do not generally tolerate! –– 4.7kΩ corresponds to almost 1.1mA.)Note that even if you have more than one device on the same I²C bus, you only need one pull-up resistor per signal line;notper device! If you use I²C voltage level translators, isolators, or I²C switches, then you will need pull-up resistor per signal line per bus "segment". You'll see that in such devices' datasheets, with pull-up resistors on SDA and SCL lines on both sides of the device.

author: tooki
author_rank: Super Contributor
timestamp: January 06, 2025, 12:35:24 pm
content: Quote from: GG on January 06, 2025, 12:42:09 amIt has little to do with what chip you’re using (other than voltage and speed), but with the bus speed and capacitance first and foremost, as well as the bus voltage (to prevent using a resistor with such low resistance that too much current flows: the maximum 3mA current required by the standard for fast mode devices, the most common kind).Here’s a TI white paper on how to select them:https://www.ti.com/lit/an/slva689/slva689.pdfThis slideshow from NXP (the successor company to Philips, which invented I2C) has step by step instructions on selecting the value, which I find a bit clearer, on slides 11-18:https://www.nxp.com/docs/en/training-reference-material/DESIGNING-WITH-I2C-BUS-DEVICES.pdfAnd of course, the official I2C standard has the official guidance (pp 43-54) but it requires very careful reading and understanding of the spec:https://www.nxp.com/docs/en/user-guide/UM10204.pdfBut in a nutshell, for the common 400kHz (“fast mode”) speed and a 5V bus, common values are perhaps 2.2k to 4.7k ohms, for 3.3V it’s often 1k to 3.3k ohms. Note that this is the total parallel resistance of all pull-up resistors that may be present on each line. I2C breakout boards often include a higher-value resistor (like 10k) so that it’s likely to work even if other breakout boards also have pull-ups installed.Higher resistance than above (e.g. 10k total) often works because we are using short buses with nowhere near the maximum bus capacitance.If you have an oscilloscope, you can also just inspect the bus and see what your rise times look like, then adjust the resistor value up or down till it looks right.

author: Peabody
author_rank: Super Contributor
timestamp: January 06, 2025, 02:49:56 pm
content: The popular ZS-042 RTC module uses 4.7K pullups. That's the one with the DS3231 and a small EEPROM.

author: GG
author_rank: Contributor
timestamp: January 06, 2025, 06:28:12 pm
content: Thank y'all very much for your replies.Special thanks to Nominal Animal and Tooki for sending me so many details and educational information, I learnt a lot and I really appreciate it.Based on everything you have sent I put this together:Vcc 3.3 VVol 0.4 VIol 3 mAtR (fast) 300 nstR (std) 1000 nsCb 400 pfTherefore if my math is correct:Rp(min) 966 ohmRp(max) 2950 ohmMeaning a2.2kresistor would be best as Nominal Animal suggested, right ??On a sidenote just for my information, would that mean that the Rp(max) for Fast Mode is 885 ohm, which is lower than Rp(min) ?? What am I missing here?

author: tooki
author_rank: Super Contributor
timestamp: January 06, 2025, 11:51:11 pm
content: Quote from: GG on January 06, 2025, 06:28:12 pmUnless you’re using very long cables (which would make no sense for an RTC) then I’m sure his suggestion will work marvelously.Quote from: GG on January 06, 2025, 06:28:12 pmWhere’s that number from?

author: GG
author_rank: Contributor
timestamp: January 07, 2025, 12:32:30 am
content: Quote from: tooki on January 06, 2025, 11:51:11 pmThe trace length is 20mm @ 0.3mm width, hope that's good and won't make any difference?Quote from: tooki on January 06, 2025, 11:51:11 pmThat number is from the same equation but using the fast mode tR number instead of the standard mode so: (300*1000)/(0.8473*400) = 885 ohm ?But I might be totally mistanken here?!

author: Nominal Animal
author_rank: Super Contributor
timestamp: January 07, 2025, 02:57:13 am
content: Fast Mode \$t_R \le 300 \text{ ns}\$ and \$C_B \le 400 \text{ pF}\$, so worst case \$R_{PU} = 750 \text{ Ω}\$. At 3.3 V logic levels, it implies 4.4 mA current (over a transistor to pull the signal line low); but the I²C standard (see e.g.this PDF summary) specifies a 3 mA maximum pull-up current from 0.4 V, so that the smallest "valid" pull-up resistance to 3.3 V per signal line is about 967 Ω ≃ 1 kΩ.In other words, we have additional limits for the I²C bus to work right. When the bus capacitance is smaller, the required pull-up resistance is smaller too. We don't want to use the maximum 3 mA either, because some devices may have marginal transistors that cannot pull the signals low enough when the current is too high –– specifically, when their on-state resistance at the base voltage and current is 1 kΩ or more. Basically, it's a balancing act.As I understand it –– myself being a hobbyist too –– proper electrical engineers check the shape (rise and fall times, or slopes) and level of the SDA and SCL signals using an oscilloscope, and tune the pull-up resistors to balance the current draw with the signal integrity. The resistor values are not precise at all, and usually a rather wide range of values tends to work fine; the tuning is mostly done to ensure the system works correctly for its entire lifetime as components age, and for all assembled systems considering individual part variations.A side note: Because all pull-up resistors on the same signal line are in parallel, adding another resistor in parallel decreases the total pull-up resistance.As you know, \$R_1\$, \$R_2\$ in parallel yield resistance \$R = 1 / (1 / R_1 + 1 / R_2)\$: for example, 4.7 kΩ and 10 kΩ in parallel yields about 3.2 kΩ. (4.7 kΩ, 6.8 kΩ, and 10 kΩ in parallel totals about 2.2 kΩ). Essentially, the total resistance of parallel resistors is always less than the smallest resistor. This is why it is "okay" to have high-value pull-ups like 10 kΩ integrated on break-out boards used in experimentation: you can always add additional pull-up resistors in parallel to decrease the pull-up resistance and increase the pull-up current.For 20mm short traces, especially if surrounded by ground plane or ground guard trace, I'd say anything between 1 kΩ and 10 kΩ should work in practice. I'd definitely default to 2.2 kΩ, but check the actual signal shape and levels on an oscilloscope to confirm.

author: tooki
author_rank: Super Contributor
timestamp: January 07, 2025, 02:15:17 pm
content: Quote from: GG on January 07, 2025, 12:32:30 amThat’s absolutely nothing.“Long” would be things like a 2m long cable.According to the spec, trace lengths under 10cm require no special treatment whatsoever, and even above that, they just specify the preferred order for the signals to run next to each other. The spec doesn’t actually specify a maximum length. As long as your cable can maintain the specified rise times and maximum capacitance, it’s ok.Quote from: GG on January 07, 2025, 12:32:30 amOK.You’re not wrong (I’m assuming your arithmetic is correct and have not checked it): for Fast Mode you’d need a stronger (lower resistance) pull-up. The part you’re “missing” is that the calculation is using the worst-case 400pF maximum-permitted bus capacitance. But you’re unlikely to be anywhere near that. Usingthis calculatorand assuming 0.3mm separation between the two 0.3mm tracks, the capacitance of the bus is just 1.3pF over 20mm. Your traces would have to be over 6m long to exceed the 400pF. (And you could just increase track spacing to compensate.)If you run the numbers using a much lower, but still wildly conservative capacitance value, for example 100pF, you’ll find you have ample headroom even for Fast Mode.

author: GG
author_rank: Contributor
timestamp: January 07, 2025, 03:17:02 pm
content: Again huge thanks to Tooki and Nominal Animal for absolutely brilliant information !!!Thank you for the capacitance calculator @ 20mm lenght, 0.3mm width, 1mm separation it is 0.92 pF + two solder joints.So now knowing about the much MUCH lower capacitance value, would it be worth using 4.7k instead for lower power consumption while still being able to use both fast and standard mode?

author: tooki
author_rank: Super Contributor
timestamp: January 07, 2025, 04:46:15 pm
content: Bear in mind that the current only flows during active data transmission (whenever the line is being driven low). So unless you’re reading the time from your RTC constantly (like many times per second, which is pointless with that RTC), the real-world difference will be tiny. At the end of the day, anything from 2.2k to 10k is likely to work absolutely fine.As previously stated, the ultimate test is to look at it with an oscilloscope and make sure it’s within reason. But I suspect you won’t have any trouble.