Troubleshooting

I2C Device Not Detected on Arduino

An I2C bus either answers or it does not. A short scan and a few wiring checks will tell you which layer has failed.

22 November 20268 min read
An Arduino with SDA and SCL jumper wires connected to an I2C module on a breadboard
Two signal lines, a shared ground and a unique address are all an I2C device needs.

Bu projeyi gerçekten kurmak istersen parçaları hobidevre.com'dan temin edebilirsin →

Build it for real

To build this project for real, get the parts from hobidevre.com → hobidevre.com →

More build guides: hobidevre.com/blog

Start with a scanner sketch

Before writing any sensor library code, run a scanner that sweeps all addresses and prints the ones that answer. With only one device connected, a single reported address means the physical bus works. An empty scan means the problem is in power, wiring or pull-ups, not in your application code.

A scanner is a diagnostic tool. Remove it from the final project once the address is known. Keeping it in a project adds serial output you do not need and can slow startup, which is why it belongs at the beginning of the investigation rather than in the finished sketch.

Check SDA, SCL, power and ground

I2C uses two signal lines: SDA for data and SCL for the clock. Swapping them stops all communication. Connect VCC to the voltage the module expects and connect the module ground to the controller ground. A missing shared ground is one of the most frequent reasons for a bus that never answers.

On an Uno, the SDA and SCL lines are also present on analogue inputs A4 and A5. Use the labelled header when your board has one, because it removes any doubt about which pin is which. Check each connection with a continuity test before running the scanner again.

Add the pull-up resistors

The I2C bus uses open-drain outputs, so both lines need a pull-up resistor to the supply. Many modules include them already, but bare sensors and some breakout boards do not. Without pull-ups, the lines never reach a valid high level and the scan returns nothing.

If your module has no resistors, add one from each line to the logic supply. A value in the low kilo-ohm range is typical for a short bus. Adding a second set of pull-ups when the module already has them is usually harmless at low speed, but it increases current, so check the board before adding parts.

Match the logic level

A device powered at five volts can present five volts on its signal lines. Connecting that directly to a three-volt controller input can damage the input or simply prevent reliable communication. Check the module requirements and the controller voltage before you trust the bus.

When the levels differ, use a level shifter designed for I2C rather than a simple resistor divider on both lines. A divider may work for one direction but fail for the other, because the bus is bidirectional. Level matching is a physical requirement, not something a library setting can fix.

Resolve address conflicts

Every device on the bus needs a unique address. Two sensors of the same type often default to the same address and then neither answers reliably. The scanner will show one address where you expected two, which is the clue that a conflict exists.

Many modules have address pins or solder pads that select one of several addresses. Change one device, then scan again to confirm both appear. If the module offers no address selection, you need a bus multiplexer or a different part for the second device.

A scanner you can trust

The scanner below sweeps the standard address range and prints each address that returns an acknowledgement. Run it with only the device under test connected. If nothing is reported, do not change the library in your main sketch; go back to power, ground, pull-ups and the two signal lines.

If an address appears, write it down in hexadecimal and use exactly that value when you create the sensor or display object. A single wrong digit in the address produces the same silent failure as a wiring fault, which is why copying the scanned value is safer than using an address from a tutorial.

After the device is detected, remove the scanner and run the real sketch. If the device worked with the scanner but not with the library, the remaining causes are a wrong address in the library call or a library that does not match your module.

#include 

void setup() {
  Serial.begin(9600);
  Wire.begin();
  Serial.println("I2C tarayici");
}

void loop() {
  int bulunan = 0;
  for (byte adres = 1; adres < 127; adres++) {
    Wire.beginTransmission(adres);
    if (Wire.endTransmission() == 0) {
      Serial.print("adres: 0x");
      Serial.println(adres, HEX);
      bulunan++;
    }
  }
  if (!bulunan) Serial.println("cihaz yok");
  delay(5000);
}

Keep the bus short and tidy

Long jumper wires add capacitance and pick up noise. A bus that works with short leads can fail when the same module is moved to the far end of a breadboard. Keep SDA and SCL together and as short as practical, and route them away from motor wires and switching supplies.

If a connection must be long, lower the bus speed and consider stronger pull-ups. Both changes improve margin. A bus that works reliably on the bench but fails when the enclosure is closed usually has a wiring layout problem rather than a code problem.

  • Scanner run with one device only
  • SDA and SCL not swapped
  • Ground shared with the controller
  • Pull-ups present on both lines
  • Logic levels compatible

Get the parts

I2C modules, level shifters and jumper wire sets are available from hobidevre.com if you want to repeat these tests.

Frequently asked questions

Can I connect two devices with the same address?

Not on one bus. Change one address with its pins or pads, or use a multiplexer.

Does a scanner damage a device?

No. It only addresses each location briefly and waits for an acknowledgement.

Why does it work at low speed but not high speed?

Long wires and weak pull-ups slow the signal edges. Shorten the bus or reduce the clock rate.

Related reading

Practise in the browser

Open the same layout in the simulator and follow the steps. Sign in to save your work.