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.
An address you have
or a PCF8574 LCD backpack
Decimal or hex (0x..). On most backpacks the A0-A2 pads are pulled high, and bridging a pad ties that pin to ground (0). Changing the chip or a jumper fills in the address above.
Wire.setClock()
16×2 LCD
Times are the bus clocks and the libraries' own delays, a lower bound: Wire's interrupt code and digitalWrite() add a few µs per byte on top. Default 100 kHz is what Wire.begin() sets.
analogRead() value
Shows what arrives at the other Arduino for each way of sending the reading in one Wire.write(), and for a signed value read back with int x = Wire.read().
Paste the master and slave sketches (one after the other)
Checks run in your browser on the code as text: addresses (reserved, master and slave agree), what Wire.write() can carry, the 32-byte buffer, code inside the onReceive / onRequest handlers, and the LCD calls. The example is the most common pattern in the reports.
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Ω.
- 0x27 is a PCF8574 with A2, A1 and A0 all high.
- Wire.begin() sets 100 kHz: TWBR = (16000000 ÷ 100000 − 16) ÷ 2 = 72.
| You send | Byte | Slave shows | Step |
|---|
5 findings
- Slave address is reserved by the I2C spec. Addresses 0x00-0x07 and 0x78-0x7F are reserved (UM10204 Table 4: general call, CBUS, Hs-mode codes, 10-bit addressing, device ID). Two Arduinos will still talk at address 1, but a real device on the bus may answer it. Use 0x08-0x77; Arduino's own examples use 8.
- delay() inside an onReceive / onRequest handler. Wire calls these handlers from the TWI interrupt, with interrupts off. millis() stops, so delay() cannot wait the time you asked: in a simulation of wiring.c with the timer interrupt blocked, delay(1000) there returned after about 5 ms. Set a flag in the handler and do the waiting in loop().
- LCD writes inside the Wire handler. Each LCD character takes about 0.2 ms (parallel) to 1.2 ms (I2C backpack at 100 kHz) of waiting, all inside the interrupt; further I2C bytes and serial input wait meanwhile. Copy the data to a volatile variable in the handler and print it from loop().
- lcd.println() on a character LCD. println adds carriage return and line feed (codes 13 and 10). The HD44780 has no control codes: 0x08-0x0F show custom-character slots, so two junk glyphs appear after the text. Use lcd.print() and setCursor().
- map(value, 0, 1023, 0, 127) uses half of the byte. One byte holds 0-255, so mapping to 0-127 throws away a bit: each step is about 39 mV instead of 20 mV. Map to 255, or send two bytes for the full 10 bits.
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:
| Address | Bits | Reserved for |
|---|---|---|
| 0x00 | 0000 000 | general call (write) / START byte (read) |
| 0x01 | 0000 001 | CBUS address |
| 0x02 | 0000 010 | a different bus format |
| 0x03 | 0000 011 | future purposes |
| 0x04-0x07 | 0000 1XX | Hs-mode controller code |
| 0x78-0x7B | 1111 0XX | 10-bit target addressing |
| 0x7C-0x7F | 1111 1XX | device 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.
| Finding | Reports | What happens |
|---|---|---|
| map(…, 0, 1023, 0, 127) | 180 | Half a byte unused: 128 steps of 39 mV instead of 256. |
| LCD writes inside onReceive / onRequest | 161 | Milliseconds of LCD waiting inside the TWI interrupt. |
| Slave at a reserved address | 158 | Address 1 in 124 (0x01 is CBUS). Works between two Unos, out of spec on a real bus. 246 use 8. |
| delay() inside the handler | 134 | Interrupts 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() | 59 | Characters 13 and 10 show as two junk glyphs after the text. |
| Voltage kept in an int | 55 | signed int voltage = (value*5)/1024 keeps whole volts: 0 to 4. |
| Negative temperature sent as a byte | 20 | Below 0 °C the slave shows 256 − |T|. |
| Master and slave addresses differ | 7 | The 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.
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
- AVR PWM calculator (TCCR registers, frequency and duty, with a code check)
- Ultrasonic distance and moving-average calculator (HC-SR04 echo timing)
- Embedded systems courses
- All free engineering tools
Sources
- NXP, UM10204 I2C-bus specification and user manual, Rev. 7.0, 1 Oct 2021: Table 4 reserved addresses, SDA/SCL characteristics (IOL 3 / 3 / 20 mA, tr 1000 / 300 / 120 ns, Cb 400 / 400 / 550 pF), 7.1 pull-up resistor sizing.
- Texas Instruments, SLVA689A I2C Bus Pullup Resistor Calculation (worked example reproduced: 966.667 Ω to 1.77 kΩ).
- Microchip, ATmega48A/PA/88A/PA/168A/PA/328/P datasheet DS40002061B: SCL frequency (22.5.2), Table 29-14 two-wire bus requirements, RPU 20-50 kΩ, ADC result (24.9).
- Arduino, ArduinoCore-avr Wire library (Wire.cpp, utility/twi.c: internal pull-ups, TWBR formula, 32-byte buffers, slave callbacks from ISR(TWI_vect)) and wiring.c (micros, delay).
- Arduino, LiquidCrystal library (pulseEnable 1 + 1 + 100 µs, clear 2 ms); LiquidCrystal_I2C (expanderWrite per nibble and enable edge, 1 + 50 µs).
- Texas Instruments, PCF8574 and PCF8574A remote 8-bit I/O expander datasheets (address byte 0100 A2 A1 A0 / 0111 A2 A1 A0).
- Hitachi, HD44780U datasheet: instruction times at 270 kHz (37 µs, 1.52 ms for clear and return home), character codes 0x00-0x0F = CGRAM.