Raspberry pi MAC address

Hi, May know how to get mac id of my board only.

i did try use "node-red-contrib-arp" but it's dashboard palette.

Your router should contain that information, otherwise you could use "Advanced IP Scanner" (Google it) to obtain the MAC address.

Try https://www.npmjs.com/package/node-red-contrib-os

One word Fing.

Perhaps more than one word would be a bit more useful here. Is that a node?

Do you mean you just need to know what it is? In which case, in a terminal on the pi, run
ifconfig
and that will show you the mac address for each network interface on the board.

or

cat /sys/class/net/wlan0/address

to directly get the wlan0 address, so you can e.g. use it with the exec node in NR.

[{"id":"583ba2f6.4012fc","type":"exec","z":"cf6706ec.415a58","command":"cat /sys/class/net/wlan0/address","addpay":false,"append":"","useSpawn":"false","timer":"","oldrc":false,"name":"","x":380,"y":100,"wires":[["cc01fefb.e547f"],[],[]]},{"id":"a6d062e9.c5ddb","type":"inject","z":"cf6706ec.415a58","name":"","topic":"","payload":"","payloadType":"date","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":160,"y":100,"wires":[["583ba2f6.4012fc"]]},{"id":"cc01fefb.e547f","type":"debug","z":"cf6706ec.415a58","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","x":630,"y":100,"wires":[]}]
2 Likes

In the time it took you to type that you could have clicked on the word and searched for an answer that would be far better than anything I could include.

Assuming it is using a wireless connection.

Yes, everyone reading this thread could have searched the term to figure out what you were referring to. Or you could have mentioned its a mobile app and saved everyone that effort.

5 Likes

I do manage to see the mac id but unable to extract the info.

@tramanah The Debug node shows msg.payload is already an Object. You do not need to parse it further.

The docs have a whole section on how to understand the structure of a message, recognise if it is a JSON string or Object and how to identify the path to any element of the message using the Debug sidebar. https://nodered.org/docs/user-guide/messages

Please have a read through of that, as much of the advice we'd give at this point is straight out of that page.

@tramanah

Try a change node, with following content

Just adapt it to whatever data you want to extract.

var obj = msg.payload;
var json = JSON.parse(obj);


var MAC = json["networkInterfaces"]["Wi-Fi"][0].mac;

msg.payload = MAC;
return msg;

Manage to get the mac id.