0Pricing
Arduino & IoT Academy · درس

البحث عن عناوين I2C

اعثر على كل جهاز في الناقل باستخدام أداة فحص.

البحث عن عناوين I2C درس مجاني في Arduino & IoT Academy على CoddyKit. هذا هو الدرس 2 من أصل 4. يمكنك قراءة الدرس كاملاً أدناه مجاناً — ثم تمرن عليه مباشرة في المتصفح باستخدام محرر أكواد مدمج ومدرس ذكاء اصطناعي متاح 24/7. هذا الدرس جزء من مسار التعلم في Arduino & IoT Academy، وتقدمك يتزامن عبر الويب وتطبيق CoddyKit. تتضمن دورة Arduino & IoT Academy 4 دروس في المجموع.

بعض أجزاء هذا الدرس لم تُترجم بعد وتظهر باللغة الإنجليزية.

Find What Is Connected

Before coding a sensor you need its address. An I2C scanner sketch finds every device on the bus for you. 🔍

Why Addresses Matter

Two devices with the same address will clash on the bus. Scanning first tells you what is there and warns of conflicts.

The Datasheet Can Lie

A datasheet lists a default address, but solder jumpers can change it. Scanning gives you the real, current value every time.

How a Scan Works

The scanner tries every address from 1 to 127 and checks who answers. Each reply means a live device sits at that spot.

Start a Transmission

To test one address you open a message with beginTransmission. It targets the device without sending real data yet.

Wire.beginTransmission(addr);

End and Read the Result

Calling endTransmission returns 0 if a device acknowledged. Any other number means nobody answered at that address.

byte error = Wire.endTransmission();

Loop Through Addresses

Wrap the test in a loop that walks from 1 to 127, checking each address once and noting which ones reply.

for (byte a = 1; a < 127; a++) {
  Wire.beginTransmission(a);
}

Print Found Devices

When a device acknowledges, print its address to the Serial Monitor so you can copy it straight into your real sketch.

Serial.print("Found device at 0x");
Serial.println(a, HEX);

Read Addresses in Hex

I2C addresses are usually shown in hex, like 0x27 or 0x3C. Printing with HEX matches the format libraries expect.

No Devices Found?

An empty scan usually means missing pull-ups, swapped SDA and SCL, or no power. Check the wiring and try again.

Your First Step Every Time

Make scanning a habit. It confirms wiring works and hands you the exact address before you write any sensor code. 🛠️

Quick Check

What does endTransmission returning 0 mean during a scan?

Recap

You can now scan the bus, walk addresses 1 to 127, and print the hex address of every device before writing real code. ✅

الأسئلة الشائعة

هل درس «البحث عن عناوين I2C» مجاني؟

نعم — نص درس «البحث عن عناوين I2C» كامل متاح مجاناً هنا على الويب. لتمرينه بشكل تفاعلي (محرر أكواد مدمج ومدرس ذكاء اصطناعي متاح 24/7) وفتح باقي دورة Arduino & IoT Academy، انتقل إلى CoddyKit PRO. تتضمن دورة Arduino & IoT Academy 4 دروس في المجموع.

ماذا ستتعلم في «البحث عن عناوين I2C»؟

اعثر على كل جهاز في الناقل باستخدام أداة فحص. تتمرن على Arduino & IoT Academy مع أكواد عملية تشغلها مباشرة في المتصفح، ومدرس ذكاء اصطناعي متاح 24/7 يجيب على أسئلتك أثناء عملك.

هل أحتاج إلى خبرة سابقة لأبدأ Arduino & IoT Academy؟

لا تُشترط خبرة سابقة. Arduino & IoT Academy على CoddyKit منظم للمبتدئين حتى المتقدمين، لذا يمكنك البدء من هنا أو من البداية والتقدم بسرعتك الخاصة. هذا هو الدرس 2 من أصل 4.

كم من الوقت يستغرق درس «البحث عن عناوين I2C»؟

معظم دروس CoddyKit تستغرق حوالي 5–10 دقائق. كل منها موجز وتفاعلي، لذا تحرز تقدماً مستمراً وتستأنف من حيث توقفت عبر الويب والتطبيق.

هل يمكنني كتابة وتشغيل أكواد في درس Arduino & IoT Academy هذا؟

نعم. كل درس في Arduino & IoT Academy يتضمن محرر أكواد مدمج، لذا تكتب وتشغل أكواداً حقيقية مباشرة في متصفحك وتحصل على تعليقات فورية من الذكاء الاصطناعي — بدون إعداد محلي.

جميع الدروس في هذه الدورة

  1. كيف يتخاطب I2C عبر سلكين
  2. البحث عن عناوين I2C
  3. كيف ينقل SPI البيانات بسرعة
  4. تشغيل عدة أجهزة على ناقل واحد
← العودة إلى Arduino & IoT Academy