Programming multiple sketches with differnet board configuration

Hi,

how can I easily programm multiple sketches with different board configurations?
I.e.
Sketch 1 for ESP32
Sketch 2 for ATTiny85
Sketch 3 for Arduino Uno

Every time I open an other sketch I have to change the board (and maybe the programmer). It would be nice to have the configration stored in the sketch folder so this will be loaded instead of a global configuration.

Currently I create a comment block and write down the configuration for each sketch. So if I find an error in sketch 1 I have to reconfigure...

Regards
Nils

"Cross-platform inclusion (exclusion?)" using #define, #ifdef and #ifndef.

Web sites once operated like this (some still do). They "read" your browser and operating system and made pages only work for your defined browser/OS.

The idea is, all your boards' code is in one file and "un-comment" the board you will use.

#define ESP32
// #define UNO
// #define ATTiny85

... and inside the code you would have the conditional statements:

#ifdef ESP32
pinMode(1, OUTPUT);
#endif

#ifdef UNO
pinMode(2, OUTPUT);
#endif

#ifdef ATTiny85
pinMode(3, OUTPUT);
#endif

You could also store information in EEPROM and read the EEPROM at startup, but I do not know how to use that.

I am certain there are better methods...

Hi, sorry for being not enough detailed.
I‘m not talking about the inclusion of multiple micro controllers for one project. The sketches are completly independent.
Sketch 1 for the ESP32 is controlling LED strips and using NTP, a web server and Email.
Sketch for ATTiny is a very simple controller for a DFPlayer.
And the Arduino Uno sketch will be a testing system for a DFPlayer with serial debugging.

So there is currently not really much code sharing between the sketches.

But if I experience an issue in the ESP project I have to reconfigure the IDE for the used ESP32. And reconfigure again if I want to work on the Uno project.

Like VSC + PlatformIO :shushing_face:

Do a search in this section of the forum for the keyword "portable"; I think that there are two topics with a workaround for the lack of a "portable install" option in IDE 2.x.

How this works in IDE 1.x:

  1. Extract the zip version somewhere on your PC.
  2. Create a directory called portable in the unzipped directory.
  3. Configure the IDE to use a specific sketchbook directory.
  4. Install required board packages and libraries.
  5. Start working by starting the IDE in the unzipped directory.

You can have multiple unzipped installations, each with their own sketchbook directory, board packages and libraries,

If you configure the sketchbook directory to be in the portable directory you can actually have a full project which includes the board package and libraries that were used for the project. Once the project is completed, never upgrade the board package and libraries of the project and as a result you will always be able to rebuild it with the versions that were used.

New project? Repeat the steps above.

As mentioned, IDE 2.x unfortunately does not have that option yet although it has been asked for.

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.