【问题标题】:Interfacing DS18B20 through Address通过地址连接 DS18B20
【发布时间】:2019-05-01 09:52:58
【问题描述】:

我有一个线设备 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])

【问题讨论】:

  • 如何同时得到编译错误和程序结果?
  • 忘了说:
  • 忘了提及:我没有将 &address 传递给 ds.select,而是传递 ds.select(address) 并且我也将地址数组声明为字节,然后我得到这个 0 0 0 0

标签: c arduino hex


【解决方案1】:

来自sources

void OneWire::select( uint8_t rom[8])

尝试:

uint8_t address[]={0x28,0xFF,0x6C,0xEA,0x62,0x16,0x4,0xE7};  
ds.select(address);

C++ 知道变量类型。

【讨论】:

  • 我仍然得到 0 0 0 0 0 0 0 0 0
猜你喜欢
  • 2013-07-18
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2018-09-15
  • 2020-05-08
相关资源
最近更新 更多