Skip to content

GetDeviceROM()

Arnd edited this page Jan 1, 2017 · 2 revisions

GetDeviceROM(DeviceIndex,ROMBuffer);

Although the library uses the deviceIndex for all DS-Family operations, the actual 8-Byte ROM addresses might be of interest, so this function will return the unique ROM address for the given deviceIndex. This function is only valid after a ScanForDevices() has been run.


Example:

uint8_t ROMBuffer[8];                        // store the unique address
char buffer[32];                             // buffer for sprintf() calls
const uint8_t ONE_WIRE_PIN = 8;              // 1-Wire microLAN pin
DSFamily_Class ds(ONE_WIRE_PIN);             // Instantiate
uint8_t thermometers = ds.ScanForDevices();  // find all devices
Serial.print("## Hex ROM Address \n");
Serial.print("== ================\n");
for(uint8_t i=0;i<ds.ThermometersFound;i++) { // loop for each thermometer
  DSFamily.GetDeviceROM(i,ROMBuffer);         // Read the unique ROM Address
  sprintf(buffer,"%02d %02X%02X%02X%02X%02X%02X%02X%02X\n", // Make formatted string
         i,ROMBuffer[0],ROMBuffer[1],ROMBuffer[2],ROMBuffer[3],
         ROMBuffer[4],ROMBuffer[5],ROMBuffer[6],ROMBuffer[7]);
  Serial.print(buffer); // Output the formatted string 
} // of for-next each thermometer found loop