You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Adafruit Featherwing Huzzah32 ESP32第二路I2C总线引脚选择咨询

Adafruit Featherwing Huzzah32 ESP32 第二路I2C总线配置说明
  • ESP32原生支持两个硬件I2C控制器,对应Arduino框架下的Wire(第一路,默认绑定23(SDA)/22(SCL))和Wire1(第二路)。
  • Huzzah32的第二路I2C有预定义默认引脚:SDA=33,SCL=32。这是Adafruit在官方板级支持包(BSP)中配置好的,直接调用Wire1.begin()就能使用这组引脚,无需额外设置。
  • 若需要自定义第二路I2C的引脚,确实可以通过Wire1.setPins(sda_pin, scl_pin)指定任意合适的GPIO,但要注意:
    • 避开输入专用引脚(34-39),因为I2C需要双向通信,这类引脚无法输出电平;
    • 尽量避开有其他硬件功能冲突的引脚(比如SPI、UART的默认引脚),避免干扰。

代码示例

使用默认第二路I2C引脚

#include <Wire.h>

void setup() {
  Wire.begin();          // 第一路I2C:23(SDA)/22(SCL)
  Wire1.begin();         // 第二路I2C:33(SDA)/32(SCL)
}

void loop() {
  // 相关I2C操作
}

自定义第二路I2C引脚(比如用14(SDA)和15(SCL))

#include <Wire.h>

void setup() {
  Wire.begin();
  Wire1.setPins(14, 15); // 指定自定义SDA/SCL引脚
  Wire1.begin();
}

void loop() {
  // 相关I2C操作
}

内容的提问来源于stack exchange,提问作者karovier

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.08.25 12:39:39