I have a project which involves a number of ESP32's with Ethernet modules reading from sensors and sending the sensor info to a Client PC running a Python app as and when the client requests said data. So that I can identify my ESP32 modules on the network, I assign them all a mac address starting EA and consisting only of numbers 0-9. This is how I do it;
Code: Select all
// start WiFi to read current mac
WiFi.begin();
WiFi.macAddress(mac );
// now set new all decimal mac starting 'EA'
mac[0]=0xEA;
for(int i= 1; i<6; i++)
{
int a = ((mac[i]%100)/10)*16;
int b = ((mac[i]%100)%10);
mac[i]=a+b;
}
Serial.begin(115200);
Serial.println("App started ..... ");
Serial.print("Unit MAC address : ");
for(int i=0; i<5; i++)
{
Serial.print(mac[i], HEX);
Serial.print(":");
}
Serial.println(mac[5], HEX);
Ethernet.init(WIZ_CS);
Ethernet.begin(mac);
I would also like to be able to offer units which are WiFi rather than PoE but I have been unable to find a way of starting the WiFi with my own mac rather than the one burned to the ESP32 chip. In the WiFi.begin process, there must be somewhere that the ESP32's mac is read from efuse and used. I know I can burn a new mac to efuse but I dont want to do that, I just want to create a new mac from the current mac, and start WiFi using my mac.
I realise that I will need to read the mac directly from efuse so that I can create my own mac before I call WiFi.begin()
Any suggestions?
Thanks, Steve.