我有单线设备 DS18b20 的地址,我想通过在数组中声明其地址来连接它,并且我想调用地址数组的初始化程序是 onewire.select(array-Initializer),然后我想计算温度,但我得到 Data = 0 0 0 0
#include <OneWire.h>
OneWire ds(10);
//byte address[8];
byte data[12];
//int a;
byte i;
byte address[]={0x28,0xFF,0x6C,0xEA,0x62,0x16,0x4,0xE7};
void setup() {
// put your setup code here, to run once:
Serial.begin(9600);
}
void loop() {
// put your main code here, to run repeatedly:
ds.reset();
ds.select(&address);
ds.write(0x44);
ds.reset();
ds.select(address);
ds.write(0xBE);
Serial.print("DATA=");
for (i=0;i<9;i++){
Serial.print(" ");
data[i]= ds.read();
Serial.print(data[i],DEC);
Serial.print(" ");
}
Serial.println();
delay(1000);
}
我也收到此错误:
no matching function for call to 'OneWire::select(byte (*)[8])
最佳答案
来自sources :
void OneWire::select( uint8_t rom[8])
尝试:
uint8_t address[]={0x28,0xFF,0x6C,0xEA,0x62,0x16,0x4,0xE7};
ds.select(address);
C++ 能够识别变量类型。
关于c - 通过地址连接 DS18B20,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53537249/