// Get build version of ESP32
//
// Set it in "diagram.json":
//   Default, version 3
//     "attrs": {}
//   Version 2
//     "attrs": {"builder": "esp32-core-2.0.7"}
//
// Result:
//   Version 2 does not compile.
//   Version 3 shows the build number
//
// Reference:
// https://github.com/espressif/arduino-esp32/blob/master/cores/esp32/Esp.h


void setup() 
{
  Serial.begin(115200);
  Serial.println();

#if defined(ESP_ARDUINO_VERSION_STR)
  Serial.print("Core (is build version): ");
  Serial.println(ESP.getCoreVersion());
#else
  Serial.println("The build version is not defined, therefor it must be version 2.");
#endif

  Serial.print("SDK version: ");
  Serial.println(ESP.getSdkVersion());

  Serial.print("Chip model: ");
  Serial.println(ESP.getChipModel());

  Serial.print("Number of cores: ");
  Serial.print((int) ESP.getChipCores());
  Serial.print(" at ");
  Serial.print((int) ESP.getCpuFreqMHz());
  Serial.println(" MHz.");

  Serial.print("Heap size: ");
  Serial.print(ESP.getHeapSize());
  Serial.print(" (");
  Serial.print(ESP.getFreeHeap());
  Serial.println(" available).");

  Serial.print("PSRAM: ");
  Serial.print(ESP.getPsramSize());
  Serial.print(" (");
  Serial.print(ESP.getFreePsram());
  Serial.println(" available).");

  Serial.print("Flash size: ");
  Serial.print(ESP.getFlashChipSize());
  Serial.print(" at ");
  Serial.print(ESP.getFlashChipSpeed());
  Serial.println(" Hz.");
}

void loop() 
{
  delay(10); // this speeds up the simulation
}