ESP32读取DS18B20温度

#include <OneWire.h>
#include <DallasTemperature.h>


// 定义DS18B20数据口连接ESP32的4号IO上
#define ONE_WIRE_BUS 4

// 初始连接在单总线上的单总线设备
OneWire oneWire(ONE_WIRE_BUS);
DallasTemperature sensors(&oneWire);
void setup() {
 // 设置串口通信波特率
  Serial.begin(9600);
  Serial.println("Dallas Temperature IC Control Library Demo");
  // 初始库
  sensors.begin();
}

// the loop function runs over and over again forever
void loop() {
Serial.print("Requesting temperatures...");
  sensors.requestTemperatures(); // 发送命令获取温度
  Serial.println("DONE");
  
  Serial.print("Temperature for the device 1 (index 0) is: ");
  Serial.println(sensors.getTempCByIndex(0));
  delay(500);  
}

arduino路径C:\Users\用户名\Documents\Arduino\libraries

gen_esp32part.py:507: UnicodeWarning: Unicode equal comparison failed to convert both arguments to Unicode - interpreting them as being unequal
 项目使用 210350 字节(16%)的程序存储空间。最大值为 1310720 字节。
 个全局变量使用 13480 个字节(4%)的动态内存,剩下 314200 个字节用于局部变量。最大值为 327680 字节。

库文件下载地址
Arduino-Temperature-Control-Library-master
https://download.csdn.net/download/qixiwl/87407746
OneWire-master
https://download.csdn.net/download/qixiwl/87407748
安装方式
项目- 包含库- 添加zip库

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

qixiwl

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值