esp32 调试温度传感器LM75

采用的是vs code 的arduino进行调试
导入lib包I2C Temperature Sensors derived from the LM75
添加到项目后
代码如下

#include <Arduino.h>
#include <Temperature_LM75_Derived.h>
//1001A2A1A0
Generic_LM75 temperature(0x48);
Generic_LM75 temperature2(0x4A);

static const uint8_t TEMP_SDA = 22;
static const uint8_t TEMP_SCL = 23;
static const uint32_t TEMP_FREQUENCY =  400000L;//400khz

void setup() {
  
  Serial.begin(9600);
  Wire.setPins(TEMP_SDA, TEMP_SCL);
  Wire.setClock(TEMP_FREQUENCY);
  Wire.begin();
}

void loop() {
  Serial.print("Temperature = ");
  Serial.print(temperature.readTemperatureC());
  Serial.println(" C");

  delay(500);

  Serial.print("Temperature2 = ");
  Serial.print(temperature2.readTemperatureC());
  Serial.println(" C");

  delay(1000);
}

需要连接VCC,GND,SDA,SCL四条线,
LM75默认地址是0x48,即1001 000
后面的三位分别是A2 A1 A0共8种组合,A与VCC连接是1,不连则表示0。

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值