Go Down

Topic: ETHERNET SHIELD How to get the MAC ADDRESS to use as a data in the main code (Read 854 times) previous topic - next topic



I would like to know if is possible to get the mac address of a ethernet shield from the arduino where the shield is connected, because I would like to use it like a data: display in a web page, send by email.....



You really shouldn't need to "get" the MAC address. Just do something like this:

Code: [Select]
byte MACaddress[] = {0, 1, 2, 3, 4, 5};  //this can be anything you like, but must be unique on your network

void setup() {
    Ethernet.begin(MACaddress);  //let the network assign an IP address

Then you have your MAC address stored in the MACaddress variable, which you can use both in Ethernet.begin() and as you like elsewhere in your code.



But what I am thinkig about is this:

Execute a code in three arduinos, setting different mac address in each one.

Later erase this code, and execute other code, the same code in these arduinos, and read its mac addres, that should be different.


When you call Ethernet.begin() you set the MAC address. That's going to be the MAC address. If you don't call Ethernet.begin() then you won't be able to use Ethernet so the MAC address will be irrelevant.

Maybe I'm just not understanding what you're trying to do. You need to provide a better explanation and probably some example code.


OK, I understand now.

I thought that if you run a code that configures the ethernet, then loads and executes another code that does not configure it, it saved the configuration of the first program (like an EPROM).


Go Up