I2C calculator: pull-ups, addresses, speed and LCD timing

Size the pull-up resistors, turn any datasheet address into the one Arduino's Wire library wants, see what Wire.setClock() really sets and how long a 16×2 LCD update takes. Then paste your master and slave sketches to check them. Free, no sign-up.

NXP UM10204 Rev. 7.0 · TI SLVA689A · ATmega328P DS40002061B · Arduino Wire + LiquidCrystal source · PCF8574 · HD44780 · Updated 20 Nov 2026

Bus

Bus capacitance: about 10 pF per device pin (ATmega328P: 10 pF max) plus the wiring, very roughly 50-100 pF per metre of jumper or ribbon. Choosing a mode fills in its sink current; the rise-time limit comes from the mode.

R min1.53 kΩ(VDD − VOL) ÷ IOL
R max11.8 kΩtr ÷ (0.8473 Cb)
Fit4.7 kΩon SDA and on SCL

Green: the allowed range. Grey: the internal pull-ups alone. Scale 300 Ω to 100 kΩ, logarithmic.

  • E12 values that fit: 1.8 kΩ, 2.2 kΩ, 2.7 kΩ, 3.3 kΩ, 3.9 kΩ, 4.7 kΩ, 5.6 kΩ, 6.8 kΩ, 8.2 kΩ, 10 kΩ.

How to size I2C pull-up resistors

I2C lines are open-drain: every device can only pull SDA and SCL low, and a resistor to VDD pulls them back high. Two limits set its value. Too small, and a device sinking its rated current (3 mA in Standard and Fast mode, 20 mA in Fast-mode Plus) cannot pull the line below 0.4 V. Too large, and the bus capacitance charges so slowly that the line misses the rise-time limit (1000 ns at 100 kHz, 300 ns at 400 kHz, 120 ns at 1 MHz). NXP's I2C specification gives both:

The 0.8473 is the time an RC curve takes to climb from 30% to 70% of VDD, the two input thresholds:

A 5 V Arduino bus at 100 kHz with 100 pF on it can use 1.53 kΩ to 11.8 kΩ; 4.7 kΩ sits in the middle. At 400 kHz the top falls to 3.54 kΩ, so use 2.2 kΩ. With 400 pF, the most the spec allows, even 100 kHz needs ≤ 2.95 kΩ. TI's application note works the 3.3 V, 200 pF Fast-mode case: 966.7 Ω to 1.77 kΩ; the calculator gives the same.

The ATmega328P datasheet writes the top limit without the 0.8473 (1000 ns ÷ Cb), which comes out 15% lower. Both are shown. And the Arduino detail most tutorials skip: Wire.begin() switches on the chip's internal pull-ups on A4 and A5. They are 20 to 50 kΩ each. Two Unos give 10 kΩ to 25 kΩ in parallel. That rises in 0.42 to 1.06 µs on 50 pF, and 0.85 to 2.12 µs on 100 pF. The limit is 1 µs. Short jumpers on a bench often get away with it; a longer cable or 400 kHz will not.

7-bit and 8-bit I2C addresses, and the LCD backpack's

An I2C address is 7 bits. On the wire it is sent as the top 7 bits of the first byte, with the read/write bit last. Many datasheets quote that whole byte, the "8-bit address": 0x4E (write) and 0x4F (read) are both the 7-bit address 0x27. Arduino's Wire library takes the 7-bit form, so halve a datasheet's 8-bit number. Sixteen of the 128 addresses are reserved by the specification:

AddressBitsReserved for
0x000000 000general call (write) / START byte (read)
0x010000 001CBUS address
0x020000 010a different bus format
0x030000 011future purposes
0x04-0x070000 1XXHs-mode controller code
0x78-0x7B1111 0XX10-bit target addressing
0x7C-0x7F1111 1XXdevice ID

A 16×2 LCD has no I2C address of its own. The address is the backpack's I/O expander. A PCF8574 answers at 0100 A2 A1 A0, so 0x20 to 0x27; a PCF8574A at 0111 A2 A1 A0, 0x38 to 0x3F. Backpacks ship with A0-A2 pulled high, which is why 0x27 and 0x3F are the two addresses everyone tries. The expander's 8 pins drive the LCD in 4-bit mode: P0 = RS, P1 = RW, P2 = E, P3 = backlight, P4-P7 = D4-D7 (LiquidCrystal_I2C's mapping).

What Wire.setClock() really sets, and how long an LCD update takes

The ATmega328P makes SCL from its CPU clock and the 8-bit TWBR register. Wire's twi_setFrequency() works TWBR out with integer maths and leaves the prescaler at 1:

At 16 MHz, 100 kHz gives TWBR = 72 and 400 kHz gives 12, both exact. Other requests round: setClock(300000) gives 307.7 kHz. 1 MHz gives TWBR = 0, below the 10 the library's own comment asks for, and beyond the ATmega328P's rated 400 kHz. Below 30.42 kHz the 8-bit register overflows: setClock(10000) computes 792, stores 24 and runs the bus at 250 kHz, 25 times faster than asked.

Each byte on the bus is 9 clocks (8 bits and the acknowledge), so a one-byte write (address + data) is about 19 clocks, 190 µs at 100 kHz, and two bytes 280 µs. The LCD backpack is where time goes. LiquidCrystal_I2C sends every character as two 4-bit halves, and each half takes three separate I2C writes (data, enable high, enable low) and a 50 µs wait. That is 6 writes per character: 1.24 ms at 100 kHz, so a full 16×2 screen (32 characters and 2 cursor moves) takes about 42.2 ms, or 45.5 ms if you clear() first. At 400 kHz it is 13.2 ms. Wired in parallel, LiquidCrystal waits 2 × 102 µs per character, 0.20 ms, so 6.94 ms a screen. Either way, calling lcd functions inside an I2C interrupt handler holds that interrupt for milliseconds.

Sending an analogRead value over I2C

analogRead() returns 0 to 1023. The datasheet's conversion is:

Dividing by 1024 is the datasheet's form. Dividing by 1023 reads at most 4.9 mV (one step) high, inside the ADC's own ±2 LSB absolute accuracy, so either is fine. The real trap is the byte. Wire.write(value) sends one byte, so a reading of 700 (3.42 V) arrives as 188 (700 − 512). The options:

  • map(value, 0, 1023, 0, 255) or value >> 2: one byte, 256 steps of about 20 mV.
  • map(value, 0, 1023, 0, 127), the common example: still one byte, but half the steps (about 39 mV).
  • Two bytes, highByte() then lowByte(), rebuilt with v = Wire.read() << 8; v |= Wire.read();: all 10 bits, 4.9 mV steps. 767 goes as 2 and 255.

Signed values break the same way. A TMP36 reading of −10 °C, (V − 0.5) × 100, goes out as the byte 246. Read with int t = Wire.read(), the slave shows 246 °C. Read into an int8_t, or add 50 before sending and subtract it after.

What 635 student sketches got wrong

Skill-Lync's embedded project "Interfacing a 16*2 LCD with Arduino using I2C protocol" asks for two Arduinos talking over I2C, with the value shown on an LCD. 635 reports are public; 561 include code, and we ran this page's checker on all of them (as of 20 Nov 2026; findings hand-checked on samples). 506 wire the LCD in parallel to the slave and use I2C only between the boards; 51 use an I2C backpack, at 0x27 in 28, 0x20 in 7 and 0x3F in 4. 265 of the 561 trip at least one check other than the map-to-127 note.

FindingReportsWhat happens
map(…, 0, 1023, 0, 127)180Half a byte unused: 128 steps of 39 mV instead of 256.
LCD writes inside onReceive / onRequest161Milliseconds of LCD waiting inside the TWI interrupt.
Slave at a reserved address158Address 1 in 124 (0x01 is CBUS). Works between two Unos, out of spec on a real bus. 246 use 8.
delay() inside the handler134Interrupts are off there, so millis() stops. In our simulation of wiring.c's delay() with the timer interrupt blocked, delay(1000) returned after about 4-5 ms, not 1 s.
lcd.println()59Characters 13 and 10 show as two junk glyphs after the text.
Voltage kept in an int55signed int voltage = (value*5)/1024 keeps whole volts: 0 to 4.
Negative temperature sent as a byte20Below 0 °C the slave shows 256 − |T|.
Master and slave addresses differ7The master's transfers are NACKed and nothing arrives.

Only 17 reports mention pull-up resistors. Most built the circuit in Tinkercad, which does not model bus capacitance, so nothing there forced the question.

What this calculator does not cover

  • Measured bus capacitance. The pull-up range is only as good as the Cb you enter. Measure the rise time on a scope for anything long or noisy.
  • Level shifting. A 5 V Uno and a 3.3 V sensor on one bus need a level shifter or pull-ups to the lower supply, as the sensor allows.
  • Exact library timing. The LCD times count bus clocks and the libraries' delays, not the CPU time of Wire's interrupt code or digitalWrite(), so real updates take a little longer.
  • Every bug. The checker reads code as text. It catches the patterns above, not logic errors, and it does not compile your sketch.
Learn embedded systems

I2C, SPI, UART and CAN drivers are the daily work of an embedded engineer. Skill-Lync's embedded programs go from Arduino to bare-metal AVR and automotive ECUs.

How we checked the calculator

The independent Python script scripts/verify/i2c.py runs 29 checks. This page recomputes every one of its results with the browser code at build time and refuses to build if they differ.

  • Reserved addresses rebuilt from the specification's bit patterns (0000 1XX and so on) for all 128 addresses; PCF8574 and PCF8574A addresses from the datasheets' address bytes.
  • TWBR computed with the same unsigned 32-bit and 8-bit arithmetic as twi.c for 20 clock/speed pairs: 72 at 100 kHz matches the library's own comment, and the overflow boundary was found by brute force.
  • Pull-ups: 0.8473 = ln(7/3) checked; TI's worked example (966.667 Ω to 1.77 kΩ) and NXP's (5.5 V, 1.7 kΩ) reproduced.
  • LCD timing by stepping through LiquidCrystal_I2C's send(), write4bits() and pulseEnable() and counting I2C writes and delays.
  • The sketch checker is a port of the Python checker we ran on the reports; both give the same findings on all 561 reports with code, and on 6 test sketches including one with no faults.

Frequently asked questions

What pull-up resistor do I need for I2C?

Any value between R min = (VDD − 0.4 V) ÷ 3 mA and R max = tr ÷ (0.8473 × Cb). For a 5 V Arduino bus at 100 kHz with 100 pF of wiring and pins, that is 1.53 kΩ to 11.8 kΩ, so 4.7 kΩ is a safe pick; at 400 kHz the top drops to 3.54 kΩ, so use 2.2 kΩ. Put one resistor on SDA and one on SCL for the whole bus, not one per device.

Does Arduino need pull-up resistors for I2C?

Wire turns on the ATmega328P's internal pull-ups on A4 and A5, which are 20-50 kΩ. Two Unos in parallel give 10 kΩ-25 kΩ; with 100 pF on the bus the rise time is 0.85-2.12 µs against Standard-mode's 1 µs limit. It often works on a short bench, as Tinkercad does, but is out of spec. Fit 4.7 kΩ resistors.

What is the I2C address of a 16x2 LCD?

The address belongs to the I2C backpack, not the LCD. A backpack with a PCF8574 is 0x20 to 0x27 (0x27 with all three address pins high, the usual factory setting); with a PCF8574A it is 0x38 to 0x3F (0x3F). Run an I2C scanner sketch if you are not sure.

Why does my LCD show 0x4E instead of 0x27?

0x4E is the same address shifted left one bit with the write bit (0) added: the 8-bit form some datasheets quote. Arduino's Wire library wants the 7-bit form, 0x27. 0x4F is the read form.

Which I2C addresses can I use?

0x08 to 0x77. The I2C specification (NXP UM10204, Table 4) reserves 0x00 to 0x07 (general call, START byte, CBUS, other bus formats, Hs-mode) and 0x78 to 0x7F (10-bit addressing and device ID).

How do I change the I2C speed on Arduino?

Call Wire.setClock(400000) after Wire.begin(). On a 16 MHz Uno it sets TWBR = 12 and gives exactly 400 kHz. Values below about 30.4 kHz do not work: TWBR is an 8-bit register and the value wraps (setClock(10000) gives 250 kHz).

How do I send a value larger than 255 over I2C?

Send two bytes: Wire.write(highByte(v)); Wire.write(lowByte(v)); and rebuild it on the other side with v = Wire.read() << 8; v |= Wire.read();. Wire.write(v) on its own sends only the low 8 bits.

Is this calculator free?

Yes. It runs in your browser, needs no sign-up and sends nothing anywhere, including the code you paste.

Related on Skill-Lync

Sources

Free counselling

From an Arduino sketch to firmware jobs.

Communication protocols, interrupts and bare-metal drivers are what embedded interviews test. A Skill-Lync counsellor can map the program that fits the role you want.

Talk to a course counsellor

Free. We call you back, usually the same day.

By submitting you agree to our Terms and Privacy Policy.

Talk to a career counsellor

Talk to a career counsellor

Free 20-minute call. We'll map the right course to where you want to work.

By submitting you agree to our Terms and Privacy Policy.