Notifications
Clear all

Getting Mac address problem

11 Posts
5 Users
2 Reactions
210 Views
robotBuilder
(@robotbuilder)
Member
Joined: 5 years ago
Posts: 2142
Topic starter  

Following Bill's tutorial...
https://dronebotworkshop.com/esp-now/
Loaded and ran the esp32-mac-address sketch but it didn't return an address?
Yes I pressed the reset button after downloading the sketch.
Any idea what I did wrong?

Also in the bottom right corner the IDE starting indexing something?
(see screen grab from bottom right of image)

getMac1

 


   
Quote
(@mike-parsons)
Member
Joined: 9 months ago
Posts: 24
 

I've been battling this for a week or two. Don't know if it's the same problem, but in my case, it returned a mac address of all zeros. For me, it turned out to be an updated library(3. something) I loaded an older version (2. something) and now it works fine. I think this video is a few years old and if you look closely, at one point, you'll see that Bill is using version 1. something.

Sorry for my version vagueness. If you think this may be your problem, I'll happily retrace my steps and give you more specific details.


   
robotBuilder reacted
ReplyQuote
robotBuilder
(@robotbuilder)
Member
Joined: 5 years ago
Posts: 2142
Topic starter  

@mike-parsons 

Thank you Mike. Problem fixed. Found this alternate sketch to obtain MAC address.

/*
  Rui Santos & Sara Santos - Random Nerd Tutorials
  Complete project details at  https://RandomNerdTutorials.com/get-change-esp32-esp8266-mac-address-arduino/ 
  Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files.  
  The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
*/
#include <WiFi.h>
#include <esp_wifi.h>

void readMacAddress(){
  uint8_t baseMac[6];
  esp_err_t ret = esp_wifi_get_mac(WIFI_IF_STA, baseMac);
  if (ret == ESP_OK) {
    Serial.printf("%02x:%02x:%02x:%02x:%02x:%02x\n",
                  baseMac[0], baseMac[1], baseMac[2],
                  baseMac[3], baseMac[4], baseMac[5]);
  } else {
    Serial.println("Failed to read MAC address");
  }
}

void setup(){
  Serial.begin(115200);

  WiFi.mode(WIFI_STA);
  WiFi.STA.begin();

  Serial.print("[DEFAULT] ESP32 Board MAC Address: ");
  readMacAddress();
}
 
void loop(){

}

   
ReplyQuote
Ron
 Ron
(@zander)
Father of a miniature Wookie
Joined: 4 years ago
Posts: 7590
 

@mike-parsons FYI @robotbuilder Looks like you missed the news, Espressif has made a lot of changes to the boards for V3. NOT library, BOARDS. There is a migration document where you can check if you are tripping on one of the changes, or just arbitrarily set your ESP32 boards entry back to 2.0.17. Here is the migration LINK

First computer 1959. Retired from my own computer company 2004.
Hardware - Expert in 1401, and 360, fairly knowledge in PC plus numerous MPU's and MCU's
Major Languages - Machine language, 360 Macro Assembler, Intel Assembler, PL/I and PL1, Pascal, Basic, C plus numerous job control and scripting languages.
My personal scorecard is now 1 PC hardware fix (circa 1982), 1 open source fix (at age 82), and 2 zero day bugs in a major OS.


   
ReplyQuote
TFMcCarthy
(@tfmccarthy)
Member
Joined: 2 months ago
Posts: 127
 

@mike-parsons 

IIRC, in esp32 v 3.x you can get the valid mac address after you call esp32.begin. This will also work on v2.x \.

edit: i meant esp_now_init

This post was modified 2 weeks ago by TFMcCarthy

   
ReplyQuote
(@mike-parsons)
Member
Joined: 9 months ago
Posts: 24
 

@zander Hi Ron. If there's one skill I've developed since I joined this forum, it's how to grab the wrong end of a stick (with both hands). Thanks, yet again, for your input, and the link to that document. Alas, I'm one of those non professionals that @robotbuilder was talking about yesterday, so I think it will be a long time (if ever) till I'll be able to understand much of it. I tend to rely on Bill, and many others, to show me in simple terms what I have to do.

 

Thanks also, to @robotbuilder and @tfmccarthy. As it stands, I've been able to get a mac address on all my various ESP32 modules, by prodding and poking at stuff I don't really understand. As I continue my journey into ESP NOW, time will tell whether my prodding and poking will have implications further down the line. I take heart from the fact more experienced guys like yourselves run into problems just like mine, although i suspect, at a much deeper level.

 

Finally, on a point of etiquette, is it ok to respond to three people in one post, or is it the done thing to reply individually? I don't want to offend anyone.


   
ReplyQuote
Ron
 Ron
(@zander)
Father of a miniature Wookie
Joined: 4 years ago
Posts: 7590
 

@mike-parsons Responding to all 3 of us at once is perfectly ok. My advice is to look at all the examples and make notes about what they do and HOW, this way when you need to do a part of example 1 and a part of example 2 you will be prepared.

First computer 1959. Retired from my own computer company 2004.
Hardware - Expert in 1401, and 360, fairly knowledge in PC plus numerous MPU's and MCU's
Major Languages - Machine language, 360 Macro Assembler, Intel Assembler, PL/I and PL1, Pascal, Basic, C plus numerous job control and scripting languages.
My personal scorecard is now 1 PC hardware fix (circa 1982), 1 open source fix (at age 82), and 2 zero day bugs in a major OS.


   
ReplyQuote
robotBuilder
(@robotbuilder)
Member
Joined: 5 years ago
Posts: 2142
Topic starter  

@mike-parsons 

Alas, I'm one of those non professionals that @robotbuilder was talking about yesterday, so I think it will be a long time (if ever) till I'll be able to understand much of it. I tend to rely on Bill, and many others, to show me in simple terms what I have to do.

Everyone relies on everyone else simply because none of us can be experts on every subject at every level and in every field. An individual comes up with a new idea or a new discovery and teaches it to others who in turn teach it to others. Teachers (and books and now google and AI) are simply links in the chain.

A library can provide different levels of control. I remember trying to understand how to use DirectX that was an overlay for different hardware graphic boards. But at the highest level those that understood the DirectX could write functions that made it easier for others to access the graphics board.

For two esp32 chips to communicate you need their phone numbers (MAC ADDRESS). After that is should be as simple as making a phone call.

SendMessage(MAC_ADDRESS,"turn on LED1")
message = GetMessage(MAC_ADDRESS)

Or something like that...

 


   
ReplyQuote
(@mike-parsons)
Member
Joined: 9 months ago
Posts: 24
 

Thanks @robotbuilder. I have to agree with everything you say in your first paragraph. Without wanting to get political, I firmly believe that, as a species, we can achieve a lot more by cooperating than by competing. That's why I love the ethos of open source stuff. Eighteen months ago, I hadn't heard of Arduino, and now here I am talking to you about making two ESP32s talk to each other. That's down to a hell of a lot of people sharing their expertise for free. I'm under no illusion that I'm going to make anything that I couldn't buy for half the price (and a tenth of the size), but I'm really enjoying the process. I find it quite amusing that I joined this thread thinking I could help YOU, and I've ended up learning a ton of stuff.

Thanks again.


   
huckOhio reacted
ReplyQuote
robotBuilder
(@robotbuilder)
Member
Joined: 5 years ago
Posts: 2142
Topic starter  

@mike-parsons 

Eighteen months ago, I hadn't heard of Arduino, and now here I am talking to you about making two ESP32s talk to each other.

I heard of the Arduino Board 5 years ago and joined this forum at that time.

Probably should have looked into the esp32 earlier (had them gathering dust on the shelf) but find it harder as I get older to get motivated to learn new things when the old things work fine. Now I am rather enthused with the esp32 and what it offers.

 

This post was modified 6 days ago 2 times by robotBuilder

   
ReplyQuote
(@aliarifat)
Member
Joined: 1 month ago
Posts: 28
 

The sketch should be designed to retrieve and print the MAC address. If you made any modifications, try running the unmodified version to see if the issue persists.


   
ReplyQuote