So you're a Noob? Post your questions here until you graduate! Don't be shy.

User avatar
By developer27
#89540 I am trying to find out if #ifdef can tell the difference between
esp8266 NodeMCU ( 30 pin breadboard version)
Wemos D1 Mini esp8266 (16 pin)

I want to make a way do something like the following,
but it sees both boards as an ESP8266

#ifdef ESP8266
const char * board = "esp8266 on breadboard";
#define DHTPIN D6
#elif WEMOS
const char * board = "D1 mini on window sill";
#define DHTPIN D4
#endif
Serial.print(board);

In the above example both boards print out as:
"esp8266 on breadboard"

Is the board def determined by the board or by the Arduino IDE?
Is there a way to print out what the compiler says the board is?
Is there any way to differentiate between these or any other boards?
Is there any code that might do the following?
Serial.print(boardDef());

My goal is to make it auto configure to the specs of the board I am uploading to without manually changing the code each time.

If no other options work, Would I be able to use LED_BUILTIN as a method of determining which board it is during compile?
User avatar
By JurajA
#89541 for selected board the xy.build.board property is used to set a compile-time variable ARDUINO_{build.board} to allow use of conditional code between #ifdefs. A build.board value is automatically generated if not defined. for example for UNO the variable defined at compile time will be ARDUINO_AVR_UNO.

https://arduino.github.io/arduino-cli/p ... #boardstxt