V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
taxze
V2EX  ›  外包

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

  •  
  •   taxze · 20 天前 · 1101 次点击

    我用的是 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

    6 条回复    2024-08-30 11:33:18 +08:00
    chopin1998519
        1
    chopin1998519  
       20 天前
    上拉电阻?

    用示波器看看波形呗
    taxze
        2
    taxze  
    OP
       20 天前
    @chopin1998519 不太懂呀,我只能写软件层功能,碰到电路真拉闸了😵
    UIXX
        3
    UIXX  
       20 天前
    看了代码,逻辑没有问题。猜想有两个:
    1. 电源,这个没有原理图跟实物测试,不好说。
    2. 引脚配置。esp32s3 系列的大部分芯片的 GPIO30 和 GPIO31 用作 SPI 的时钟线和输出线,官方是不推荐使用这些引脚另作他用的。
    56rssd
        4
    56rssd  
       20 天前
    先 Wire.pins(31,30)再 Wire.begain()试试
    skyyan2000
        5
    skyyan2000  
       20 天前
    这是啥,怎么感觉向线束测试得模块上得
    maja
        6
    maja  
       19 天前
    i2c 调不通永远先检查有没有上拉...
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   实用小工具   ·   3710 人在线   最高记录 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 21ms · UTC 00:54 · PVG 08:54 · LAX 17:54 · JFK 20:54
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.