0Pricing
Arduino & IoT Academy · Lesson

Scan for I2C Addresses

Find every device on the bus with a scanner.

Scan for I2C Addresses is a free Arduino & IoT Academy lesson on CoddyKit — lesson 2 of 4. You can read the complete lesson below for free — then practise it hands-on in the browser with a built-in code editor and a 24/7 AI tutor. It is part of the Arduino & IoT Academy learning path, one of 4 lessons in the course, and your progress syncs across the web and the CoddyKit app.

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. ✅

Frequently asked questions

Is the “Scan for I2C Addresses” lesson free?

Yes — the full text of “Scan for I2C Addresses” is free to read here on the web, and the Arduino & IoT Academy course includes 4 lessons in total. To practise it interactively (a built-in code editor and a 24/7 AI tutor) and unlock the rest of the Arduino & IoT Academy course, upgrade to CoddyKit PRO.

What will I learn in “Scan for I2C Addresses”?

Find every device on the bus with a scanner. You practise Arduino & IoT Academy with hands-on code you run directly in the browser, and a 24/7 AI tutor answers your questions as you work through the lesson.

Do I need any experience to start Arduino & IoT Academy?

No prior experience is required. Arduino & IoT Academy on CoddyKit is structured for beginners through advanced learners; this is — lesson 2 of 4, so you can start here or from the beginning and move at your own pace.

How long does the “Scan for I2C Addresses” lesson take?

Most CoddyKit lessons take about 5–10 minutes. Each one is bite-sized and interactive, so you make steady progress and pick up exactly where you left off across the web and the app.

Can I write and run code in this Arduino & IoT Academy lesson?

Yes. Every Arduino & IoT Academy lesson includes a built-in code editor, so you write and run real code right in your browser and get instant AI feedback — no local setup required.

All lessons in this course

  1. How I2C Talks on Two Wires
  2. Scan for I2C Addresses
  3. How SPI Moves Data Fast
  4. Run Several Devices on One Bus
← Back to Arduino & IoT Academy