#include <OneWire.h>
#include <DallasTemperature.h>
// 引脚定义
#define ONE_WIRE_BUS 15
//库引用实例
OneWire oneWire(ONE_WIRE_BUS);
DallasTemperature sensors(&oneWire);
void setup(void)
{
Serial.begin(9600);
sensors.begin();
}
void loop(void)
{
sensors.requestTemperatures(); // 发送命令获取温度
Serial.print("Temperature for the device 1 (index 0) is: ");
Serial.println(sensors.getTempCByIndex(0));
delay(100);
}
标签:WIRE,oneWire,arduino,esp32,ds18b20,实例,void,sensors,Serial From: https://www.cnblogs.com/aker-whale/p/17434717.html