首页 > 解决方案 > 将 I2C HDC1080 温度传感器添加到 esp32cam

问题描述

ESP32cam 没有用于 I2C 传感器的引脚,您必须使用您必须通过软件更改引脚的传感器。

在我的第一个方法中,我可以运行 I2C 扫描仪,在我的 esp32cam 上的 0x40 地址中找到我的 HDC1080 传感器

    #include <Wire.h>
#define I2C_Freq 100000
#define SDA_0 14 //change pin data
#define SCL_0 15 //change pin clock
TwoWire I2C_0 = TwoWire(0);
void setup()
{
  Serial.begin(115200);
  I2C_0.begin(SDA_0 , SCL_0 , I2C_Freq);
}

我现在遇到的问题是使用此引脚与 HDC1080 配合使用,为此我使用 ClosedCube_HDC1080 库

我尝试以这种方式修改 ClosedCube_HDC1080.cpp,但没有成功:

#include <Wire.h>
#define I2C_Freq 100000
#define SDA_0 15
#define SCL_0 14
#include "ClosedCube_HDC1080.h"

ClosedCube_HDC1080::ClosedCube_HDC1080()
{
}

void ClosedCube_HDC1080::begin(uint8_t address)
{
    _address = address;
    //Wire.begin();
    TwoWire I2C_0 = TwoWire(0);
    I2C_0.begin(SDA_0, SCL_0, I2C_Freq);
    setResolution(HDC1080_RESOLUTION_14BIT, HDC1080_RESOLUTION_14BIT);
}

我的方法不对,欢迎任何帮助

标签: esp32arduino-esp32

解决方案


推荐阅读