Duplicate MAC addresses?

It finally happened. After flashing dozens of ESP devices, I have a NodeMCU and a Sonoff Basic (ESP8266) that both have the same MAC address.

This would explain why both have been acting screwy.

Can I spoof one of them with a different MAC address?

On an ESP8266 the core might offer a wifi_set_macaddr() API
(Appeared in the forum a few times, eg ESP8266 ESP_NOW [SOLVED] - #5 by Toby_97)

try

#include <ESP8266WiFi.h>
uint8_t newMACAddress[] = {0x42, 0x42, 0x42, 0x07, 0x07, 0x07}; // whatever

And in the setup, after WiFi.mode()

if you are in access point mode

wifi_set_macaddr(SOFTAP_IF, newMACAddress);

Or if you are in station mode

wifi_set_macaddr(STATION_IF, newMACAddress)

Thanks, but it didn't make any difference. The library has the wifi_set_macaddr() method but apparently the MAC address is hard-coded.

I could swap the NodeMCU, but it's soldered in.

Another oddity I noticed is that no matter which USB port that I plug the NodeMCU into, Windows says it is "COM4". A second NodeMCU is saying it's on COM47 even though it's on the same USB port.

Yes the MAC address is hardcoded but I thought you can bypass that. Did you try out ?

I’m a Mac / Unix guy so can’t comment on windows oddity

1 Like

I even flashed it with ESPHome and got the same MAC address of the other device. There is only six wires soldered to the NodeMCU, so I will just replace it and find a non-WiFi use for the old one.

Ok… bummer.

Hth
" Get ESP32/ESP8266 MAC Address and Change It (Arduino IDE) | Random Nerd Tutorials

Stranger and stranger.

The code from RandomNerdTutorials that you referenced works. Sort of. In my experiments, you have to reconnect WiFi after calling the wifi_set_macaddr() function. Then the chip reports a new MAC and a new DHCP IP address.

To keep my NodeMCU's straight- the one with the strange behavior, I'll call "Node A".

Node A reports it's MAC address as B4:F3:EB:1A:C4:E4 and its IP as 192.168.1.166. This is the same MAC and IP of an existing Sonoff Mini. Having the same IP and MAC was causing both devices to act screwy.

Node A also connects to the PC as COM4, NO MATTER which USB port it's plugged into.

Running the test code from RandomNerdTutorial does NOTHING to this board.

Node B, another NodeMCU, acts more normal. Different USB ports connect to the PC with different COM ports, and the wifi_set_macaddr() function does change the MAC address.

I think it's time to replace the NodeMCU (A) board.

possibly indeed

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.