How to convert MAC address from sketch to router

Can anyone help me convert the MAC address we list in the sketch that is uploaded to the arduino to a format that I can use with my router?

I need to take this:

byte mac = { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED };

and turn it into something like this:

00:1f:f3:d7:09:4c

I have an Apple Airport Extreme router and I’m trying to use the DHCP Reservation Setup to create a static IP address that I can use for the Ethernet Shield but I need to list the MAC address for the shield in the setup along with the IP address.

Thanks!

You mean like: byte mac[] = { 0x00, 0x1F, 0xF3, 0xD7, 0x09, 0x4c }; ?

de:ad:be:ef:fe:ed

at a guess.....

Yes! That worked!

Using the default mac address listed in the examples for the shield:

0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED

I can get my static IP address setup and working with my Apple Airport Extreme router using the DHCP Reservation Setup as long as I provide the MAC address of:

de:ad:be:ef:fe:ed

Now can you tell me how to make that conversion? Its fine for now but if I ever add another ethernet shield I'm going to have a problem.

Thank You!

I thought it was self evident, but apparently not.

Knock the 0x off the front of each element, switch them to lower case and them put them back together with a colon between them.

I guess I’m asking for something a little deeper. I realized that for this example the letters just dropped down into a row. Thank you, I didn’t know that prior to this. Now I’m just looking for more information on how to do a conversation that would cover all scenarios.

A mac address is always 6 bytes long, how they are seperated varies, but is usually colons. They are invariably expressed in hexdecimal notation (base 16, uses the characters 0-9 + A-F - each byte uses 2 characters since 16 * 16 is 256). Sometimes the letters are upper case, sometimes lower case, but never mixed. IP addresses on the other hand are now 4 bytes (until IPv6 happens) and almost always expressed in Decimal format as a number 0 - 255.

On a more involved level (which you don't really need to know for setting up routers and stuff) mac addresses are usually unique to a device and you can't have more than 1 of that number on a local (non routed) network. The first 3 bytes designate the manufacturer and the last three are a number given to it at manufacture by the maker. That doesn't mean to say they can't be changed or spoofed and often are. The mac address isn't routable over TCP/IP (the internet) so devices with the same mac address can exist on the internet at large. Real Mac addresses usually start with zero (00) since they haven't got past 65536 different manufacturers yet.

What else do you need to know ?

pluggy,

Thanks for that extra information. That is helpful. Just so that I understand, what number base is the sketch in? Is that hexadecimal? I guess I'm having a hard time understanding what the '0x' represents in front of the characters. I guess this isn't important now that I know I can simply change some of the letters to create another unique mac address for future ethernet shields.

Just out of curiosity are you able to convert the mac address 00:1f:f3:d7:09:4c that I used as an example in my first post to the format that you would use in the sketch?

Just out of curiosity are you able to convert the mac address 00:1f:f3:d7:09:4c

Just out of curiosity, did you read reply #1?

Is that the correct format then?

00:1f:f3:d7:09:4c

is..

byte mac[] = { 0x00, 0x1F, 0xF3, 0xD7, 0x09, 0x4c };

or should it be..

byte mac[] = { 0x00, 0x1F, 0xF3, 0xD7, 0x09, 0x4C };

Sorry to drag this out. If that's it lets consider this subject done.

Hopefully this will help others who run into this problem with getting the shield setup with an Apple router.

1 Like