The goal is to read the MAC address from a DS2502-E48 chip.

I think I accomplished this goal too with the following code, but I can't get behind at how this works. I had a similar program with a PIC chip as reference.

I checked several references about OneWire and the DS2502 but not the info I needed to hop to the right memory addresses. Where'd I normally attain the information so that I know I have to write: cc ,f0 , 0, 10 , read a random byte, and then I'm at the right position for MAC.

#include <OneWire.h>

OneWire ds(2);
void setup()   

  byte i;
  byte dataLength;
  byte present = 0;
  byte data[12];
  byte addr[8];

  if ( !ds.search(addr)) {
    Serial.print("No more addresses.\n");


  delay(1000);     // maybe 750ms is enough, maybe not

  present = ds.reset();  
  if (present != 1 )
    Serial.println("No device present, exiting...");

    ds.write(0);  // ?
    ds.write(10); // ?
    ds.read();    // ?
    dataLength = ds.read();

    for ( i = 0; i < dataLength; i++) {           
    data[i] = ds.read();
    if ( i>3){
      Serial.print(data[i], HEX);
      Serial.print(" ");

void loop()                     


From the DS2502 datasheet:

Skip ROM [CCh]

This command can save time in a single-drop bus system by allowing the bus master to access the memory functions without providing the 64-bit ROM code. If more than one slave is present on the bus and a read command is issued following the Skip ROM command, data collision will occur on the bus as multiple slaves transmit simultaneously (open drain pulldowns will produce a wired-AND result).


The Read Memory command is used to read data from the 1024-bit EPROM data field. The bus master follows the command byte with a 2-byte address (TA1=(T7:T0), TA2=(T15:T8)) that indicates a starting byte location within the data field. An 8-bit CRC of the command byte and address bytes is computed by the DS2502 and read back by the bus master to confirm that the correct command word and starting address were received. If the CRC read by the bus master is incorrect, a reset pulse must be issued and the entire sequence must be repeated. If the CRC received by the bus master is correct, the bus master issues read time slots and receives data from the DS2502 starting at the initial address and continuing until the end of the 1024-bit data field is reached or until a reset pulse is issued. If reading occurs through the end of memory space, the bus master may issue eight additional read time slots and the DS2502 will respond with a 8-bit CRC of all data bytes read from the initial starting byte through the last byte of memory. After the CRC is received by the bus master, any subsequent read time slots will appear as logical 1s until a reset pulse is issued. Any reads ended by a reset pulse prior to reaching the end of memory will not have the 8-bit CRC available.

So you are telling it that you want to read the memory from whatever device is on the bus, not any one specific one (since you are not needing to provide the ROM ID to identify the exat item on the bus), starting from address ((0 << 8) |10) = 10.

From the DS2502-E48 datasheet you can see the layout of the memory:

The data record starts with a length byte (0Ah) and the 4-byte UniqueWare Project ID 00001129h. The next 6 bytes contain the 48-bit node address which consists of an incrementing 24-bit extension identifier and the IEEE-assigned 24-bit company ID value 006035h. An inverted 16-bit CRC ends the data record. The remaining bytes of the 32-byte memory page remain unprogrammed. Neither the 24-bit extension identifier nor the 24-bit company ID are related to the 64-bit ROM registration number. The ROM registration number is used to provide a unique address to access the DS2502-E48 when multidropped on a 1-Wire bus.

So translating that into something more pictorial:

// Length byte
0x00: 0x0A

// UniqueWare PID
0x01: 0x00
0x02: 0x00
0x03: 0x11
0x04: 0x29

// Serialization ("extension") number
0x05: 0x?? 
0x06: 0x?? 
0x07: 0x??

// Company ID Value
0x08: 0x??
0x09: 0x??
0x0A: 0x??

// 16-bit CRC
0x0B: 0x??
0x0C: 0x??

// All the rest is EEPROM data
0x0D - 0x7F: 0x??

So by starting at address 10 (0x0A) you are reading the last byte of the company ID, the CRC, and then whatever else is in the memory after that.

To read the entire MAC address (least significant byte first) you should be starting to read at address 5.


I found a nice writeup on this on a blog. To quote his experimental findings:

Comparing to the OneWire spec, we can tell it’s writing 0xCC, which should be SKIP_ROM. Following that is 0xF0 (ReadMem), and two bytes starting address: 0x08, 0x00.

Based on this, the zero and 10 that you are writing are apparently an address value.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.