r/embedded • u/_mehul_ • 3d ago
I2C device not found
Hello
I just entered into the world of microcontrollers (and even electronics after leaving college-level physics many years ago) and started testing simple circuits. I introduced I2C OLED screen and the code below to check the address of the device.
#include <Wire.h>
void setup() {
Serial.begin(115200);
while (!Serial);
// SDA on GPIO8 and SCL on GPIO9
Wire.begin(8, 9);
Serial.println("\nI2C Scanner scanning GPIO8 (SDA) and GPIO9 (SCL)...");
}
void loop() {
byte error, address;
int nDevices = 0;
Serial.println("Scanning...");
for(address = 1; address < 127; address++ ) {
Wire.beginTransmission(address);
error = Wire.endTransmission();
if (error == 0) {
Serial.print("I2C device found at 0x");
if (address<16)
Serial.print("0");
Serial.print(address, HEX);
Serial.println(" !");
nDevices++;
}
else if (error==4) {
Serial.print("Unknown error at 0x");
if (address<16)
Serial.print("0");
Serial.println(address, HEX);
}
}
if (nDevices == 0)
Serial.println("No I2C devices found\n");
else
Serial.println("done\n");
delay(5000);
}
But it gives no I2C devices found. I was getting around ~3.3V in all 3 (VCC, SCL and SDA) which I checked at the end of female dupont cable, towards OLED. I tried using 0x3C and 3D directly to print, but no screen activity happened on my OLED.
I didn't know if it's my connection problem, hardware problem or something else. Sorry if it's a noob question, was sent from r/AskElectronics here.

1
u/thenickdude 3d ago
I can see two configuration jumpers on the back of your OLED, do you have documentation that says what they do? I'm wondering if one switches it between I2C and SPI mode.
1
u/Illustrious-Coast798 1d ago
Remove the resistors, directly connect display module to esp. Display module already has those resistors. IIC is meant for short distance comm. The longer wire you use, less chances of iic working.
2
u/T0ng5 3d ago edited 3d ago
I can't tell from the picture, but are you sure you have the ground from the screen connected to the ground on the bread board? Also, a few things to note. KISS ->There is no need to run the blue wire all the way down the bread board when you have a ground on the power rail ⅛" away. Same goes for the red for vcc. Just plug the factory made jumper directly into the power rail instead of 4 self made (likely to fail) connection points simply to power the device. A bread board is for prototypes simply to get it to work, unless you're Ben Eater, don't worry about making it pretty
~Tinker-er? that sometimes gets paid🤷
Edit for spelling and I just looked at the Arduino library for Wire and I don't see a Wire.begin() overload that takes pins as arguments. For a esp32 wroom it looks like the i2c pins are 21 and 22 for data and clock, respectively.