Search code examples
esp8266i2carduino-idearduino-esp8266esp8266wifi

i2cdetect doesn't showing any address


I'm using an OLED 128*64 display screen with NodeMCU ESP8266. when I tried to detect the screen address, the serial monitor shows: enter image description here

It would be kind if someone can tell me what is the problem ? and how t solve it ?


Solution

  • Hi Mari please try this I2c tester: it will give you the number of devices and their addresses

    #include <Wire.h>
    
    byte errorResult;           // error code returned by I2C 
    byte i2c_addr;              // I2C address being pinged
    byte lowerAddress = 0x08;   // I2C lowest valid address in range
    byte upperAddress = 0x77;   // I2C highest valid address in range
    byte numDevices;            // how many devices were located on I2C bus
    
    void setup() {
      Wire.begin();             // I2C init
      Serial.begin(115200);       // search results show up in serial monitor
    }
    
    void loop() {
        if (lowerAddress < 0x10)                                // pad single digit addresses with a leading "0"
      Serial.print("0");
      Serial.print(lowerAddress, HEX);
      Serial.print(" to 0x");
      Serial.print(upperAddress, HEX);
      Serial.println(".");
    
      numDevices = 0;
    
      for (i2c_addr = lowerAddress; i2c_addr <= upperAddress; i2c_addr++ ) 
        // loop through all valid I2C addresses
      {
        Wire.beginTransmission(i2c_addr);                     // initiate communication at current address
        errorResult = Wire.endTransmission();                 // if a device is present, it will send an ack and "0" will be returned from function
    
        if (errorResult == 0)                                 // "0" means a device at current address has acknowledged the serial communication
        {
          Serial.print("I2C device found at address 0x");
    
          if (i2c_addr < 0x10)                                // pad single digit addresses with a leading "0"
            Serial.print("0");
    
          Serial.println(i2c_addr, HEX);                      // display the address on the serial monitor when a device is found
          numDevices++;
        }
      }
    
      Serial.print("Scan complete.  Devices found: ");
      Serial.println(numDevices);
      Serial.println();
    
      delay(10000);                                           // wait 10 seconds and scan again to detect on-the-fly bus changes
    }