Go Down

Topic: handling onewire-ROM-IDs storing in a single variable (Read 53 times) previous topic - next topic

StefanL38

Hello,

I'm pretty new to the coding-language C++. I want to use mutliple onewire temperature-sensors.
Each onewire-device (short 1W-device) has a globally unique ROM-ID which is 8 byte long. This ROM-ID is received as 8 bytes and stored in an array of bytes.

Code: [Select]
byte addr[8];


In a setup-process I will readout each ROM-ID which is connected to the 1W-bus.
And assign each ROM-ID to a certain variable.

SensorROM_ID_bath, SensorROM_ID_kitchen etc.


Then I want to use these variables SensorROM_ID_bath, SensorROM_ID_kitchen to readout the temperatures

bathTemp = readTemp(SensorROM_ID_bath);

kitchenTemp = readTemp(SensorROM_ID_kitchen);


Now I'm looking for an efficient how to realise this.


Is it possible to compare two arrays as whole arrays?
in a codeline like shown below?

Code: [Select]

byte addr[8];
byte SensorROM_ID_bath[8];

if addr == SensorROM_ID_bath
// do the bath-things


if addr == SensorROM_ID_kitchen
// do the kitchen-things



as a general question:
before posting this question here I tried a lot of searches with different keywords.
Google will always find something but not very relevant things.

It is easy to post new questions here. I guess similar questions have been posted a dozen times.
But it seems to be hard to find the relevant postings.
Do you happen to know how to do a search  in that way that relevant hits have a high probability?

best regards 

Stefan

Riva

If your using an 8 bit MCU then you can fit 64 bits (8 bytes) into a long long  data type (long long SensorROM_ID_bath = 0x1122334455667788) or a more polymorphic version that should work correctly on 8, 16, & 32 bit MCU is to use the int64_t data type
Don't PM me for help as I will ignore it.

Go Up