首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >i2cdetect没有显示任何地址

i2cdetect没有显示任何地址
EN

Stack Overflow用户
提问于 2021-08-25 08:32:41
回答 3查看 692关注 0票数 0

我使用的是带有NodeMCU ESP8266的OLED 128*64显示屏。当我试图检测屏幕地址时,串行监视器显示:在这里输入图像描述

如果有人能告诉我问题出在哪里,那就太好了?怎么解决不了?

EN

回答 3

Stack Overflow用户

回答已采纳

发布于 2021-09-04 16:52:26

嗨,Mari,请试试这个I2c测试器:它会告诉你设备的数量和地址。

代码语言:javascript
复制
#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
}
票数 1
EN

Stack Overflow用户

发布于 2021-09-02 16:58:50

接线应用于I2C连接: D2 -> SDA、D1 -> SCL、GND -> GND、(*) -> Vcc。

(*)检查您的oled型号,一些工作在+5V,另一些工作在+3.3V,这可能是一个问题,而且通常不需要拔起电阻(检查您的型号规格)也检查您的oled的规格,有时需要一些跳线装置。

票数 0
EN

Stack Overflow用户

发布于 2021-09-12 11:37:13

我发现了问题:我没有正确地插入板内的nodemcu。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/68919461

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档