Get board name in your code

Issue #1507

Sometimes you write your application for different ESP32 boards and have to assign e.g. GPIO’s different depending on the board your app is compiled for and running on.

The easiest way is the use the #define ARDUINO_BOARD which is created by the toolchain from the board name in the boards .json file.

So in your platformio.ini file you might have defined the different boards like

The boards names are defined in [YOUR_PATH_TO_PLATFORMIO].platformio\platforms\espressif32\boards. Open the .json file for your boards and look for “name”: “Adafruit ESP32 Feather”
For the esp32dev board you find in esp32dev.json the name Espressif ESP32 Dev Module
for the featheresp32 you find in featheresp32.json the name Adafruit ESP32 Feather

So in your code you might use this like:



One comment

  • Hi,

    very useful tutorials and explanations, thanks a lot.
    I saw we coud contact you a SW dev for hire
    I’d like to discuss with a SW development using ESP32.
    Please feel free to PM me.

    Thank you,


Leave a Reply

Your email address will not be published. Required fields are marked *

Free Link Directory