i2cdetect 不显示任何地址

i2cdetect doesn't showing any address

我正在使用 OLED 128*64 显示屏和 NodeMCU ESP8266。 当我尝试检测屏幕地址时,串行监视器显示: enter image description here

如果有人能告诉我问题出在哪里,我会很高兴的。以及如何解决它?

接线应为 I2C 连接: D2 -> SDA,D1 -> SCL,GND -> GND,(*) -> Vcc

(*) 检查您的 oled 型号,一些在 +5V 下工作,其他在 +3.3V 下工作,这可能是问题所在 此外,通常不需要上拉电阻(检查您的型号规格) 还要检查你的 oled 的规格,有时需要一些跳线设置

你好 Mari,请试试这个 I2c 测试仪:它会给你设备的数量和它们的地址

#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
}

我发现了问题:我没有把nodemcu正确地插入板子里。