How should I store WiFi credentials in public project?

I’m wanting to upload a project I made to GitHub as a portfolio piece. Right now, it stores my WiFi SSID and password as plain text in main.cpp.
Is there a common way to avoid this?

I know there are general solutions to this. But they mainly rely on storing credentials in files separate from the project. And that’s not really an option for microcontrollers, especially if I want it to be platform-independent.

  1. Put your secrets in a dedicated config file, like /config/secret.yml
  2. git-ignore the secret file:
  3. Load your secret config from PlatformIO config:
  4. You can keep a template for the secret config in the repo:
  5. Pass your secret values to the project as global MACRO values:
  6. Use the values in your code:
1 Like