I was wondering if there is a way to pass parameters to an arduino sketch at the upload step.

Edit: The reason this would be helpful is because I have a bunch of esp8266 units that need to have details about their specific location but changing variables around per upload feels tedious.

If this is not possible the other solution that I am probably going to try is to have a sketch to just flash these details to eeprom and then read it from there whenever it is needed. Also storing them in eeprom feels a bit better than as literals in these sketches.


2 Answers 2


Every ESP8266 has a unique MAC address. You could that information to distinguish between the different units.

Something like if( mac='00:0a:95:9d:68:16' ){ ... }

  • Yes but I need each unit to know where it is located, I do not want to have an external lookup for its location.
    – Chris Ryan
    May 18, 2016 at 18:43
  • You could store all the locations in an array in your code. Then use the MAC address to look up the right location from the list. The only downside is that you need to know the locations and mac-addresses ahead of time.
    – Gerben
    May 18, 2016 at 18:49

Another option, if you can afford the pins, is to install DIP switches or ground-jumpers on a few pins and set / wire a different n-bit code onto each board. Set those pins to INPUT_PULLUP, read them at setup, and wallah! each board is unique. You can put the lookup table (binary number -> parameter string, f/ex) in Flash so it doesn't take up scarce RAM.

  • To add to the above, you could use two pins with dip switches and add resisters to make a ladder. then just read the R value?
    – CapeCoder
    Jan 24, 2017 at 14:21
  • In that case you'd only need one (analog) pin.
    – JRobert
    Jan 30, 2017 at 15:04

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.