Notifications
Clear all

Need help with finding mac-adress of a Pico W using arduino IDE

64 Posts
5 Users
9 Likes
2,111 Views
frogandtoad
(@frogandtoad)
Noble Member
Joined: 3 years ago
Posts: 1478
 

@zander

Posted by: @zander
Posted by: @frogandtoad

@frits1956

Posted by: @frits1956

Unfortunately, it turned out not to be the solution I thought.
This file gives the mac addresses of the access points and not of the Pico W.
Does anyone have a code to find out the mac address of the Pico W?

Thanks in advance

Just a thought... if you know the IP address, all you have to do is ping the device, and then check the arp (address resolution protocol), cache from your command prompt.

Running "arp -a" will display the arp table with all the IP to MAC address mappings, which is available on Windows, Mac and Linux.

This can be a lot quicker than compiling and uploading scripts.

Cheers

Of course now he will want to know how to find out his IP. 

As I said, *if* he was able to ping the device, then that pinging action would enter its MAC details into the "arp cache table" with the relevant MAC address mapped to that specific IP address.

OP clearly does not acknowledge this fact or your suggestions for that matter!

Cheers


   
ReplyQuote
Frits1956
(@frits1956)
Eminent Member
Joined: 2 years ago
Posts: 30
Topic starter  

@frogandtoad 

I don't know how to ping when the Pico is connected to my Android phone's hotspot.

On my phone I see that I am connected to one device so I know the connection has been established.

At the same time, I see all available Wi-Fi networks on the serial monitor.

I've tried several libraries, but I can't get the following part to work. Keep getting all kinds of errors.

byte mac[6];
WiFi.macAddress(mac);
printMacAddress(mac);

I have tryed <WiFi.h> <ESP8266WiFi.h> <WiFi101> <WiFiNINA>


   
ReplyQuote
Will
 Will
(@will)
Noble Member
Joined: 1 year ago
Posts: 2120
 

@frits1956 

Try page 17 of https://datasheets.raspberrypi.com/picow/connecting-to-the-internet-with-pico-w.pdf

I was kidnapped by mimes.
They did unspeakable things to me.


   
ReplyQuote
Frits1956
(@frits1956)
Eminent Member
Joined: 2 years ago
Posts: 30
Topic starter  

@will 

Thanks for your suggestion.

I tryed to understand the document but it is mostly python en a few pages SDK.

I have searched it several times but to me they both are abracadabra. I only know a bit of Arduino C and... I am allready connected to internet with the Pico W. For a specific program I only need to know the MAC and that drives me to crazy :C

Please keep in mind, My knowledge is limited, at my age it is not easy to learn new computer languages and English is not my native so I do not understand everything I read on internet.


   
ReplyQuote
Ron
 Ron
(@zander)
Famed Member
Joined: 2 years ago
Posts: 3416
 

@frits1956 I just hooked up my PICOW and here is the result. Pics show PICOW connected with sketch in the backgtound, My MAC from my router admin page, BSSID (MAC) from the sketch output, the board selection, and the sketch from File/Exampls/WiFi/ScanNetworks

IMG 7131
Screen Shot 2022 08 12 at 10.33.36
Screen Shot 2022 08 12 at 10.35.12
Screen Shot 2022 08 12 at 10.34.47
Screen Shot 2022 08 12 at 10.40.50

 

"Don't tell people how to do things. Tell them what to do and let them surprise you with their results.” - G.S. Patton, Gen. USA
"Never wrestle with a pig....the pig loves it and you end up covered in mud..." anon


   
ReplyQuote
Frits1956
(@frits1956)
Eminent Member
Joined: 2 years ago
Posts: 30
Topic starter  

@zander Ron, I have seen the same result but is the mac address shown from your router or from your Pi. I think from your router because all the networks availlable shows different mac addresses.

Second reason I believe it is from your router because when I put the address in the mac filter table the application still can not get a connection. I know for sure the SSID and password are oke because I use a library with these credentials and other boards (Wemos D1 for instance) with this application connect without any problems.


   
ReplyQuote
Ron
 Ron
(@zander)
Famed Member
Joined: 2 years ago
Posts: 3416
 

@frits1956 Sorry, you are right. Add the following code to just after the delay(5000) in the main loop

  byte mac[6];
  WiFi.macAddress(mac);
  Serial.print("MAC: ");
  printMacAddress(mac);

And then add the following to the very end of the file AFTER THE LAST }

void printMacAddress(byte mac[]) {
  for (int i = 5; i >= 0; i--) {
    if (mac[i] < 16) Serial.print("0");
    Serial.print(mac[i], HEX);
    if (i > 0) Serial.print(":");
  }
  Serial.println();
}

Now the output will look like in the picture, and your PICOW's MAC is the line labelled MAC, the first thing printed

Screen Shot 2022 08 12 at 11.45.44

 

 

 

"Don't tell people how to do things. Tell them what to do and let them surprise you with their results.” - G.S. Patton, Gen. USA
"Never wrestle with a pig....the pig loves it and you end up covered in mud..." anon


   
ReplyQuote
Frits1956
(@frits1956)
Eminent Member
Joined: 2 years ago
Posts: 30
Topic starter  

@zander Ron, It took a while, meshed up (is this the expression?) the ino file so had to search for a virgin one but now we are getting somewhere. I found a Mac adres ...... Thanx!!!!

My head is exploding (have been searching for 6 hours) and I am going to sleep now.

Tomorrow with a brisk feeling I will start again and post the result here.

 

Thanks for your patience and help.


   
Ron reacted
ReplyQuote
Frits1956
(@frits1956)
Eminent Member
Joined: 2 years ago
Posts: 30
Topic starter  

Today I tried for more than 5 hours to connect the Pi Pico to the router through the application.
Assuming that the MAC address found yesterday is correct, the checked application with a Wemos D1 R1 and a Wemos D1 R2 both are functioning perfect, I have to conclude that for me there is an insurmountable problem at the moment. I'll put it on hold for now.
Maybe in the future, who knows.........


   
ReplyQuote
Ron
 Ron
(@zander)
Famed Member
Joined: 2 years ago
Posts: 3416
 

@frits1956 What is 'the application'. What do you mean by 'connect the Pi Pico to the router'

Why is a MAC involved?

"Don't tell people how to do things. Tell them what to do and let them surprise you with their results.” - G.S. Patton, Gen. USA
"Never wrestle with a pig....the pig loves it and you end up covered in mud..." anon


   
ReplyQuote
Ron
 Ron
(@zander)
Famed Member
Joined: 2 years ago
Posts: 3416
 

@frits1956 Try to explain what it is you are trying to do as if you were telling a 10 yr old. NO technical terms like MAC address.

"Don't tell people how to do things. Tell them what to do and let them surprise you with their results.” - G.S. Patton, Gen. USA
"Never wrestle with a pig....the pig loves it and you end up covered in mud..." anon


   
ReplyQuote
Frits1956
(@frits1956)
Eminent Member
Joined: 2 years ago
Posts: 30
Topic starter  

I myself wrote a program for a museum that needs an internet connection for time so a museum clock can work. The program works on a wemos and arduino with wifi for some years now.

The museum's internet has a specific protection called mac filtering.

Another programmer wrote a program for a Pi Pico to drive model trains. Now they want to use my clock program to drive a route.

The program works on the Pico W. without mac filtering, but I've been trying to connect to the museum's router for a week. For some reason I can't. It's frustrating.....


   
ReplyQuote
Ron
 Ron
(@zander)
Famed Member
Joined: 2 years ago
Posts: 3416
 

@frits1956 Ok, I think I understand enough now to say I think you have 2 separate issues. The first is will the PICOW actually work as intended. The way to test that is to 'connect' it to something like your home router. That eliminates the MAC filtering issue. If it works on some unprotected router then we know the issue is in the MAC filtering, if it doesn't work on a normal router then the new 'train' software is the problem. Give that a try and let us know. I strongly suspect the software on the PICOW is at fault since MAC filtering is fairly trivial.

Do you understand what I am suggesting?

EDIT Oops, I see you already did that test. If the PICOW works on a normal router then the protected router is doing something more than just MAC filtering, OR the router/PICOW connection is substantially different than the old clock.

"Don't tell people how to do things. Tell them what to do and let them surprise you with their results.” - G.S. Patton, Gen. USA
"Never wrestle with a pig....the pig loves it and you end up covered in mud..." anon


   
ReplyQuote
Frits1956
(@frits1956)
Eminent Member
Joined: 2 years ago
Posts: 30
Topic starter  

The program on a Wemos D1 R1, Wemos D1 R2 and on a FUNduino (a kind of uno with wifi) works fine with the filtering of the museum. Therefor it is so frustrating....

I stripped the test program down to just getting the time from the internet. The train program is not yet in it. So only connecting the pico W to the museum's router remains. This is the test program I use, only the dutch comments removed. I have tested all the commented libraries..........

//Libraries ----------------------------------------------- ---------
//#include <WiFi.h>              // for WiFi shield
//#include <WiFi101.h>        // for WiFi 101 shield or MKR1000
#include <ESP8266WiFi.h>// for Wemos D1 (= ESP8266 board)

#include<WiFiClient.h>
#include<WiFiServer.h>
#include<WiFiUdp.h>
#include<NTPClient.h>

#include <Netwerk_Telefoon.h> // Network Hotspot credentials
//#include <Netwerk_TO.h>          // Network Museum credentials (checked over and over 🙁  )

NTPClient timeClient(ntpUDP, "europe.pool.ntp.org", 7200, 60000);

void setup() {
Serial.begin(9600);
WiFi.begin(ssid, password);
while ( WiFi.status() != WL_CONNECTED )
{ delay ( 500 );
serial.print( "." );
}
timeClient.begin();
}

void loop() {
timeClient.update();
Serial.println(timeClient.getFormattedTime());
delay(1000);
}

 

oeps. the library did not copy, I will add them


   
ReplyQuote
Ron
 Ron
(@zander)
Famed Member
Joined: 2 years ago
Posts: 3416
 

@frits1956 I am just trying the PICOW sample server sketch. Once I know it works you should try it as well. If it works on a 'normal' router, then try the protected router (after changing SSID and password of course) If it works as I suspect, then the problem is in the 'train' software.

"Don't tell people how to do things. Tell them what to do and let them surprise you with their results.” - G.S. Patton, Gen. USA
"Never wrestle with a pig....the pig loves it and you end up covered in mud..." anon


   
ReplyQuote
Page 2 / 5