multiple dallas ds18b20

hi guys hopefully this is in the right spot

i am trying to read multiple dallas ds18b20 sensors with the dallastemp library, i am having trouble using and array to index the read address

hopefully the question will make more sense with the code below.

its not the whole program just the bits i am trying to work with atm

i am trying to index a for loop to read the temps and write them to bytes in an array

i assume the array called prob_numbers needs to be something other than byte array

DeviceAddress p1 = { 0x28, 0xd3, 0xaf, 0x35, 0x05, 0x00, 0x00, 0x23 };
DeviceAddress p2 = { 0x28, 0xd3, 0xaf, 0x35, 0x05, 0x00, 0x00, 0x23 };
DeviceAddress p3 = { 0x28, 0xd3, 0xaf, 0x35, 0x05, 0x00, 0x00, 0x23 };
DeviceAddress p4 = { 0x28, 0xd3, 0xaf, 0x35, 0x05, 0x00, 0x00, 0x23 };
DeviceAddress p5 = { 0x28, 0xd3, 0xaf, 0x35, 0x05, 0x00, 0x00, 0x23 };


 

// this array is wrong not sure how to pass these values to sensors.getTemp()
 byte      probe_number[5] = {p1, p2, p3, p4, p5};
  




for(a = 0; a < 5; a++)
  {

  tempC = sensors.getTempC(probe_number[a]);
  current_temp[a] = (float) tempC;
 
  Serial.println(room_names[a]);
  Serial.println(current_temp[a]);
  Serial.println();
  delay(500);
  }

thanks in advance

You really need to post the whole code and not just part of it. What is DeviceAddress? Is it a datatype or a macro or something else?

DeviceAddress p1[] = { 0x28, 0xd3, 0xaf, 0x35, 0x05, 0x00, 0x00, 0x23 };

Is the usual way to create arrays but without knowing what DeviceAddress is, it may not work.

// this array is wrong not sure how to pass these values to sensors.getTemp()
 byte      probe_number[5] = {p5[0], p5[1], p5[2], p5[3], p5[4]};

This seems a more sensible way of reading a 5 byte address from the array.

with not understanding the dallastemp library very well i beleive that DeviceAddress is a variable or maybe even a function that gets a 64bit or 8 byte address passed to

i have not been able to find any info on the library or its commands only looking at code examples and reading between the lines

you have to define the adresses as below

DeviceAddress p1 = { 0x28, 0xd3, 0xaf, 0x35, 0x05, 0x00, 0x00, 0x23 };
DeviceAddress p2 = { 0x28, 0xd3, 0xaf, 0x35, 0x05, 0x00, 0x00, 0x23 };
DeviceAddress p3 = { 0x28, 0xd3, 0xaf, 0x35, 0x05, 0x00, 0x00, 0x23 };
DeviceAddress p4 = { 0x28, 0xd3, 0xaf, 0x35, 0x05, 0x00, 0x00, 0x23 };
DeviceAddress p5 = { 0x28, 0xd3, 0xaf, 0x35, 0x05, 0x00, 0x00, 0x23 };

witch is then used by the commands of the library one example is,

tempC = sensors.getTempC(deviceaddress);

i am currently doing it like this

DeviceAddress p1 = { 0x28, 0xd3, 0xaf, 0x35, 0x05, 0x00, 0x00, 0x23 };
DeviceAddress p2 = { 0x28, 0xd3, 0xaf, 0x35, 0x05, 0x00, 0x00, 0x23 };
DeviceAddress p3 = { 0x28, 0xd3, 0xaf, 0x35, 0x05, 0x00, 0x00, 0x23 };
DeviceAddress p4 = { 0x28, 0xd3, 0xaf, 0x35, 0x05, 0x00, 0x00, 0x23 };
DeviceAddress p5 = { 0x28, 0xd3, 0xaf, 0x35, 0x05, 0x00, 0x00, 0x23 };


float tempC;

int probenumber[] = {p1, p2, p3, p4, p5};
char * names[] = {"PROBE 1", "PROBE 2", "PROBE 3", "PROBE 4", "PROBE 5"};
int current_temp[5];



void loop()

  sensors.requestTemperatures();
     
  tempC = sensors.getTempC(p1);
  current_temp[0] = (float) tempC;

  tempC = sensors.getTempC(p2);
  current_temp[1] = (float) tempC;

  tempC = sensors.getTempC(p3);
  current_temp[2] = (float) tempC;

  tempC = sensors.getTempC(p4);
  current_temp[3] = (float) tempC;

  tempC = sensors.getTempC(p5);
  current_temp[4] = (float) tempC;

i would like to make the p1-5 into and array to save repeating the code for each read but it may not be possibe

something like (assume that the serial has been started and dallatemp library has been included)

DeviceAddress p1 = { 0x28, 0xd3, 0xaf, 0x35, 0x05, 0x00, 0x00, 0x23 };
DeviceAddress p2 = { 0x28, 0xd3, 0xaf, 0x35, 0x05, 0x00, 0x00, 0x23 };
DeviceAddress p3 = { 0x28, 0xd3, 0xaf, 0x35, 0x05, 0x00, 0x00, 0x23 };
DeviceAddress p4 = { 0x28, 0xd3, 0xaf, 0x35, 0x05, 0x00, 0x00, 0x23 };
DeviceAddress p5 = { 0x28, 0xd3, 0xaf, 0x35, 0x05, 0x00, 0x00, 0x23 };

float tempC;

int probenumber[] = {p1, p2, p3, p4, p5};
char * names[] = {"PROBE 1", "PROBE 2", "PROBE 3", "PROBE 4", "PROBE 5"};
int current_temp[5];



void loop()

for(a=0; a<=5; a==);
{
  tempC = sensors.getTempC(probenumber[a]);
  current_temp[a] = (float) tempC;

serial.println(names[a]);
serial.println(current_temp[a])

 }

thanks

bowie_2004: i have not been able to find any info on the library or its commands only looking at code examples and reading between the lines

You haven't been trying hard enough.

http://www.hacktronics.com/Tutorials/arduino-1-wire-tutorial.html

Note it includes two separate programmes, one to sniff the addresses, and the other to use them.