esp32 - 将 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);
}
我的方法不对,欢迎任何帮助
解决方案
推荐阅读
- if-statement - 赛普拉斯:测试元素是否存在
- javascript - 使用字符串命令来处理进程
- delphi - 在 C++ Builder 中使用 TEmbeddedWB
- asp.net-core - 当我将禁用属性放在 html 输入标签 asp.net-core mvc 中时没有映射它
- django - 带有 AWS SQS 的 Django + Celery - 在 localhost 而不是 AWS 上运行并且没有收到消息
- c# - 使用“HasConversion()”或任何其他方法将字符串转换为 Fluent API (EF Core) 中的 HierarchyId?
- python - Django:在多个模型中搜索
- c# - 如何将 mm/dd/yyy 转换为日期时间并保存在 c# 中的 sql 中?
- c# - 构建“.Net Standard”项目时——这是什么意思?
- python - 使用 Django 发表评论后如何重定向到同一页面