ESP8266 - Mac address retrieval


Hello everyone, I’ve been trying to retrieve the device’s mac address. For instance, I’m using a standard
ESP8266 nodeMCU.

  1. My goal is: Retrieve de device Mac address in a way I can use it further.

  2. My actions are: I’ve pasted the sample code as follows:

let rpcMC =, 'Sys.GetInfo', null, function(resposta, ud) 
  print('MAC address:', resposta.mac);
}, null);

Edit: When trying to put the function inside the below timer, I received a calling non-callable feedback.

Timer.set(1000, Timer.REPEAT, rpcMC())


This sample code works just fine, but I want to be able to use the Mac address further on (to create a thing name in AWS).

  1. The result I see is: - This RPC call returns a bunch of information regarding the device, including the mac address, and the function prints it out, but since the ‘resposta’ variable does not exist outside the function, I’m trying to print it in a timer of just somewhere else.

  2. My expectation & question is: I expect to be able to use this MAC address to create a thing name inside AWS further down the road.



Just call the config-get function, or call theRPC if you wish, you’ll get a JSON object, parse that object and save what you care for in a global variable.

let client_id = Cfg.get('');
1 Like

on the specifics of AWS, just leave your thing ID empty in your mos.yml and mOS will do it for you

 - ["aws.thing_name", ""]

If you can read spanish: this

1 Like

Hello scaprile,

Thank you, I have managed to do it over RPC and parse the object using jq.

As for the AWS, I made a bash script using AWS CLI to create a thing for me using the MAC Address as part of the thing name, such as:

MAC=$(mos call Sys.GetInfo | jq ‘.mac’ -r)

aws iot create-thing --thing-name KO_$MAC