목차 보기
  1. I2C의 구조
  2. 풀업 저항 값 정하기
  3. 전압 맞추기
  4. 주소와 충돌
  5. 배선 요령
  6. 안 될 때 점검 순서
  7. 정리
Table of contents
  1. The structure of I2C
  2. Deciding the pull-up resistor value
  3. Matching voltages
  4. Addresses and conflicts
  5. Wiring tips
  6. The order to check when it does not work
  7. Summary

I2C는 선 두 개(SDA, SCL)로 여러 개의 센서와 표시기를 연결하는 통신 방식입니다. 배선이 간단해서 온도 센서, OLED 화면, 시계 모듈처럼 만능기판 작품에 매우 자주 쓰입니다. 그런데 "분명히 연결했는데 장치가 안 보인다"는 문제가 가장 흔하고, 대부분 풀업 저항, 주소, 배선, 전원 중 하나가 원인입니다. 이 글에서는 I2C 버스의 구조, 풀업 저항 값을 정하는 법, 장치 주소 문제, 안 될 때의 점검 순서를 정리합니다.

I2C의 구조

  • SDA: 데이터 선
  • SCL: 클럭 선
  • 마스터: 통신을 시작하고 클럭을 만드는 장치(마이크로컨트롤러)
  • 슬레이브: 센서·표시기 등 장치. 각 장치는 고유한 7비트 주소를 가집니다.

SDA와 SCL은 오픈 드레인 방식입니다. 장치는 선을 Low로만 당길 수 있고, High는 풀업 저항이 전원 쪽으로 끌어올려서 만듭니다. 그래서 풀업 저항이 없으면 선이 올라가지 못해 통신이 되지 않습니다.

모드속도비고
표준 모드100kHz가장 안정적, 입문 기본
빠른 모드400kHz많은 센서·OLED가 지원

풀업 저항 값 정하기

값이 너무 크면 선이 느리게 올라가 신호가 둔해지고, 너무 작으면 장치가 선을 Low로 당길 때 전류가 커져서 문제가 됩니다.

  • 일반적인 값: 3.3V·5V 버스에서 4.7kΩ(100kHz), 빠른 모드나 선이 긴 경우 2.2kΩ ~ 3.3kΩ
  • 최솟값: 장치가 당길 수 있는 전류(보통 3mA)로 결정됩니다. R_min ≈ (전원 − 0.4V) ÷ 3mA이므로 3.3V에서 약 1kΩ, 5V에서 약 1.5kΩ입니다.
  • 최댓값: 선의 용량(C)과 요구되는 상승 시간으로 결정됩니다. R_max ≈ 상승 시간 ÷ (0.85 × C). 표준 모드의 상승 시간 한도는 1000ns이므로 C = 100pF이면 약 11.8kΩ까지 가능합니다.

SDA와 SCL 각각에 풀업 저항 한 개씩(두 개)을 둡니다. 저항 값 읽는 법은 저항 읽는 법을 참고하세요.

전압 맞추기

I2C의 High는 풀업이 연결된 전원 전압입니다. 3.3V 장치와 5V 장치를 한 버스에 섞으면 안 됩니다.

  • 모든 장치가 같은 전압에서 동작하도록 하거나,
  • 서로 다르면 양방향 레벨 시프터를 쓰세요(3.3V와 5V 신호 연결).
  • 5V 풀업이 3.3V 마이크로컨트롤러 핀에 걸리지 않도록 하세요.

주소와 충돌

각 장치는 7비트 주소(0x08 ~ 0x77 범위의 값)를 가지며 같은 버스에서 겹치면 안 됩니다.

  • 센서 모듈에는 주소를 바꾸는 점퍼나 핀(A0, A1)이 있는 경우가 많습니다.
  • 같은 종류의 장치를 여러 개 쓰려면 주소 핀으로 나누거나, I2C 멀티플렉서(TCA9548A 등)로 채널을 나눠 쓰세요.
  • 어떤 주소가 응답하는지 확인하려면 마이크로컨트롤러로 I2C 스캐너 프로그램을 실행하면 연결된 장치의 주소를 모두 출력합니다.

배선 요령

  • 짧게: 100kHz에서 수십 cm 이내가 안정적입니다. 길어지면 선 용량이 늘어 풀업을 줄이고 속도를 낮춰야 합니다.
  • SDA와 SCL을 나란히 두되 다른 신호선과 떨어뜨립니다. 클럭 선은 이웃 선에 잡음을 줍니다.
  • 공통 접지: 모든 장치의 GND를 연결합니다. 접지가 없으면 신호 기준이 달라 통신이 안 됩니다(전원 레일과 접지 설계).
  • 장치마다 100nF을 전원 핀 가까이에 답니다.
  • 만능기판에서는 SDA와 SCL을 점퍼선으로 가볍게 연결하고, 풀업 저항은 마이크로컨트롤러 쪽 한 군데에 모아 두면 관리하기 쉽습니다.

안 될 때 점검 순서

순서확인방법
1전원장치의 VCC 전압(3.3V/5V)이 맞는지 측정
2접지모든 GND가 이어져 있는지 도통 시험
3SDA·SCL 위치서로 바뀌지 않았는지, 핀 번호가 맞는지 확인
4풀업선이 평소 High인지 측정(0V이면 풀업 없음 또는 쇼트)
5전압장치와 마이크로컨트롤러의 논리 전압이 같은지
6주소스캐너 프로그램으로 주소 확인, 충돌 점검
7속도문제가 있으면 속도를 100kHz로 낮춰 시험
8파형오실로스코프나 로직 분석기로 신호 확인(오실로스코프 입문)

SDA나 SCL이 평소에도 Low라면 어떤 장치가 선을 잡고 있거나 쇼트입니다. 평소에도 High가 아닌 중간 전압이라면 풀업이 없거나 너무 큰 것입니다. 대부분의 문제는 점검표 1~4단계에서 찾을 수 있습니다(완성했는데 동작하지 않을 때: 단계별 점검표).

정리

I2C는 SDA·SCL 두 선과 각각 풀업 저항(보통 4.7kΩ), 공통 접지, 같은 논리 전압, 겹치지 않는 주소로 이루어집니다. 모듈에 풀업이 이미 달려 있는지 확인하고, 선을 짧게 하며, 안 되면 전원과 주소부터 점검하세요. 보드를 만능기판에 올리는 방법은 개발 보드를 만능기판에 올리는 법에서 이어서 볼 수 있습니다.

I2C is a communication method that connects several sensors and displays with two wires (SDA and SCL). The wiring is simple, so it is used very often in perfboard projects, for things like temperature sensors, OLED screens, and clock modules. But "I connected it clearly, yet the device does not show up" is the most common problem, and it is mostly caused by one of the pull-up resistors, the address, the wiring, or the power. This article covers the structure of an I2C bus, how to decide pull-up resistor values, device address problems, and the order to check when it does not work.

The structure of I2C

  • SDA: the data line
  • SCL: the clock line
  • Master: the device that starts communication and makes the clock (the microcontroller)
  • Slave: devices such as sensors and displays. Each device has a unique 7-bit address.

SDA and SCL are open drain. A device can only pull the line Low, and High is made by a pull-up resistor lifting it toward the supply. So without pull-up resistors, the line cannot rise and communication does not work.

ModeSpeedNotes
Standard mode100 kHzMost stable, the beginner default
Fast mode400 kHzSupported by many sensors and OLEDs

Deciding the pull-up resistor value

If the value is too large, the line rises slowly and the signal dulls; if too small, the current becomes large when a device pulls the line Low, which causes problems.

  • Typical value: 4.7 kΩ on a 3.3 V or 5 V bus (100 kHz), and 2.2 kΩ to 3.3 kΩ for fast mode or long lines
  • Minimum: decided by the current a device can sink (usually 3 mA). R_min ≈ (supply − 0.4 V) ÷ 3 mA, so about 1 kΩ at 3.3 V and about 1.5 kΩ at 5 V.
  • Maximum: decided by the line capacitance (C) and the required rise time. R_max ≈ rise time ÷ (0.85 × C). The standard mode rise-time limit is 1000 ns, so with C = 100 pF you can go up to about 11.8 kΩ.

Put one pull-up resistor each on SDA and SCL (two in total). For how to read resistor values, see Reading Resistors.

Matching voltages

The High of I2C is the supply voltage the pull-ups are connected to. Do not mix 3.3 V and 5 V devices on one bus.

  • Make all devices work at the same voltage, or
  • if they differ, use a bidirectional level shifter (Connecting 3.3V and 5V Signals).
  • Make sure a 5 V pull-up does not end up on a 3.3 V microcontroller pin.

Addresses and conflicts

Each device has a 7-bit address (a value in the range 0x08 to 0x77) and these must not overlap on the same bus.

  • Sensor modules often have a jumper or pins (A0, A1) that change the address.
  • To use several of the same kind of device, separate them with the address pins, or split channels with an I2C multiplexer (such as the TCA9548A).
  • To check which addresses respond, run an I2C scanner program on the microcontroller, and it prints the addresses of all connected devices.

Wiring tips

  • Short: within tens of centimeters is stable at 100 kHz. If longer, the line capacitance rises and you have to reduce the pull-ups and lower the speed.
  • Run SDA and SCL side by side but away from other signal lines. The clock line injects noise into neighboring lines.
  • Common ground: connect the GND of all devices. Without ground, the signal references differ and communication fails (Power Rails, Grounding, and Decoupling Capacitor Placement).
  • Put a 100 nF close to each device's power pin.
  • On perfboard, connect SDA and SCL lightly with jumper wires, and keeping the pull-up resistors together in one place on the microcontroller side makes them easy to manage.

The order to check when it does not work

StepCheckMethod
1PowerMeasure that the device's VCC voltage (3.3 V/5 V) is right
2GroundContinuity-test that all GNDs are connected
3SDA and SCL positionsCheck they are not swapped and the pin numbers are right
4Pull-upsMeasure that the lines are normally High (0 V means no pull-up or a short)
5VoltageCheck the device and microcontroller logic voltages are the same
6AddressCheck addresses with a scanner program, look for conflicts
7SpeedIf there is a problem, lower the speed to 100 kHz and test
8WaveformCheck the signal with an oscilloscope or logic analyzer (Oscilloscope Basics)

If SDA or SCL is Low even at rest, a device is holding the line or there is a short. If it sits at an in-between voltage, not High, at rest, there is no pull-up or it is too large. Most problems can be found in steps 1 to 4 of the checklist (It Is Finished but It Does Not Work: A Step-by-Step Checklist).

Summary

I2C consists of the two lines SDA and SCL, a pull-up resistor on each (usually 4.7 kΩ), a common ground, the same logic voltage, and non-overlapping addresses. Check whether the modules already have pull-ups, keep the wires short, and when it fails, check power and addresses first. How to mount a board on perfboard continues in Mounting a Development Board on Perfboard.

이 글은 학습 목적의 일반적인 안내입니다. 부품마다 규격과 핀 배열이 다를 수 있으니 실제 작업 전에는 사용하는 부품의 데이터시트를 확인하세요. 안전과 관련된 작업은 항목별 주의 사항을 먼저 읽고 진행하세요.This article is general guidance for learning purposes. Specifications and pinouts differ between parts, so check the datasheet of the part you use before real work. For safety-related work, read the cautions for each item first.