Hamza Abbasi
Hamza Abbasi

Reputation: 23

Interfacing DS18B20 through Address

I have address of one wire device DS18b20, I want to interface it by declaring its address in an array and i want to call the initializer of the address array is onewire.select(array-Initializer) and then i want to compute the temperature, but i am getting 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);
} 

I am also getting this error:

no matching function for call to 'OneWire::select(byte (*)[8])

Upvotes: 0

Views: 335

Answers (1)

KamilCuk
KamilCuk

Reputation: 141010

From sources:

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

try:

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

C++ is aware of variable types.

Upvotes: 1

Related Questions