ခဏလေး ဒီလိုပဲ စဉ်းစားကြည့်
I2C (Inter-Integrated Circuit) က device များစွာကို wire ၂ ချောင်းတည်း (SDA data + SCL clock) ဖြင့် bus တစ်ခုပေါ် ချိတ်ဆက်နိုင်တဲ့ protocol ပါ — device တစ်ခုစီမှာ unique address ရှိပြီး, Pi က address နဲ့ ခွဲခြားပြီး ဘယ် device ကို ဆက်သွယ်ချင်တာလဲ ဆုံးဖြတ်ပါတယ်။ SPI (Serial Peripheral Interface) ကတော့ pin ပိုများပေမယ့် (MOSI, MISO, SCLK, CS) speed ပိုမြန်ပါတယ် — high-speed sensor/display module တွေမှာ သုံးလေ့ရှိပါတယ်။
လက်တွေ့ scenario နဲ့ ချိတ်ကြည့်မယ်
I2C temperature sensor, OLED display, real-time clock module တွေကို I2C bus (SDA/SCL pin ၂ ခုတည်း) မှာ series ချိတ်ဆက်လို့ရပါတယ် — device များစွာချိတ်ထားရင် i2cdetect -y 1 command ကို run ရင် ချိတ်ဆက်ထားတဲ့ device address list ကို scan ပြသပေးပါတယ် (troubleshooting အတွက် အသုံးဝင်ပါတယ်)။ raspi-config ထဲမှာ I2C interface ကို enable လုပ်ရပါမယ် (Camera interface လိုပဲ default disabled)။
အတူတူ ကြည့်မယ်
# Enable I2C interface
sudo raspi-config
# Interface Options → I2C → Enable
# Install i2c-tools
sudo apt install i2c-tools
# Scan for connected I2C devices
i2cdetect -y 1i2cdetect -y 1 ကို run ရင် grid table ပေါ်လာပြီး, ချိတ်ဆက်ထားတဲ့ device address (ဥပမာ 0x3c) ကို highlight ပြသပေးမည်။၅ မိနစ် စမ်းကြည့်
I2C sensor module (ရှိရင်) ကို ချိတ်ဆက်ပြီး i2cdetect -y 1 ကို run ကြည့်ပါ — device address ကို ဖော်ထုတ်ကြည့်ပါ။
သတိလေးတစ်ချက်
I2C bus ပေါ် device များစွာ ချိတ်ထားတဲ့အခါ address conflict (device ၂ ခု address တူ) ရှိရင် communication error ဖြစ်နိုင်ပါတယ် — device datasheet ကနေ default address ကို double-check ပါ။