请教下 V 社大神,关于 esp32 的相关问题(付费寻找技术支持)

21 天前
 taxze

我用的是 esp32 S3 的芯片,使用下方展示的代码,扫不到任何 i2c 设备,而且会卡在 Wire.begin(31,30),然后无限 setup 。不传引脚则正常运行,提示"No I2C devices foundn"。

#include <Wire.h>

void setup() {
    Wire.begin(31,30);
    Serial.begin(115200);
    Serial.println("nI2C Scanner");
    byte error, address;
    int nDevices;
    Serial.println("Scanning...");
    nDevices = 0;
    for(address = 1; address < 127; address++ ) {
        Wire.beginTransmission(address);
        error = Wire.endTransmission();
        if (error == 0) {
            Serial.print("I2C device found at address 0x");
            if (address<16) {
                Serial.print("0");
            }
            Serial.println(address,HEX);
            nDevices++;
        }
        else if (error==4) {
            Serial.print("Unknown error at address 0x");
            if (address<16) {
                Serial.print("0");
            }
            Serial.println(address,HEX);
        }    
    }
    if (nDevices == 0) {
        Serial.println("No I2C devices foundn");
    }
    else {
        Serial.println("donen");
    }
    delay(5000);  
    Serial.print("i2c devices found:");
    Serial.println(nDevices); 
}

void loop() {

}

因为电路图是外包公司画的(我再也不找外包了😭),现在做了几个样板,用起来有一些问题,电路图我看不太懂,现在在找靠谱的大神,付费请教一些问题。有相关经验的可以➕V:Taxze2019

1107 次点击
所在节点    外包
6 条回复
chopin1998519
21 天前
上拉电阻?

用示波器看看波形呗
taxze
21 天前
@chopin1998519 不太懂呀,我只能写软件层功能,碰到电路真拉闸了😵
UIXX
21 天前
看了代码,逻辑没有问题。猜想有两个:
1. 电源,这个没有原理图跟实物测试,不好说。
2. 引脚配置。esp32s3 系列的大部分芯片的 GPIO30 和 GPIO31 用作 SPI 的时钟线和输出线,官方是不推荐使用这些引脚另作他用的。
56rssd
21 天前
先 Wire.pins(31,30)再 Wire.begain()试试
skyyan2000
21 天前
这是啥,怎么感觉向线束测试得模块上得
maja
20 天前
i2c 调不通永远先检查有没有上拉...

这是一个专为移动设备优化的页面(即为了让你能够在 Google 搜索结果里秒开这个页面),如果你希望参与 V2EX 社区的讨论,你可以继续到 V2EX 上打开本讨论主题的完整版本。

https://www.v2ex.com/t/1068612

V2EX 是创意工作者们的社区,是一个分享自己正在做的有趣事物、交流想法,可以遇见新朋友甚至新机会的地方。

V2EX is a community of developers, designers and creative people.

© 2021 V2EX