Go Down

Topic: MAC Address must be "even" for my 5100 Ethernet Shield to get DHCP address (Read 120 times) previous topic - next topic

autefrum

I have just spent several hours solving a problem, and want to save others some precious time:


I am writing some code for an ethernet shield, and was picking a MAC address randomly and assigning it thus:

Code: [Select]
byte mac[] = { 0x77, 0xAB, 0x66, 0xEF, 0x41, 0x45 };

before calling the following in my setup code:

Code: [Select]
if (Ethernet.begin(mac)==0) {
    Serial.println("DHCP failed.");
}


If the the eight bit of my MAC address was 1, this code always failed. If the eigth bit of my MAC address was 0, this code worked.

I have since learnt that the 7th and 8th bit of MAC addresses are special:
Bit 8 == 0 for unicast
Bit 8 == 1 for multicase

Bit 7 is also special - 0 = globally unique (assigned to a manufacturer to use) and 1 = locally administered (we should use these addresses!)

I found this out here: Wikipedia MAC address article

aryeduino

Hi, Thanks for the heads-up.
I would be happy to see a code that I can use with the DHCP.

I am not sure that I understand what is needed to be done thoroughly.
Please let me know. Thanks

sstaub

Try this website for generating a MAC address https://www.hellion.org.uk/cgi-bin/randmac.pl?scope=local&type=unicast

Go Up