I’m trying to inject some credentials via the platformio.ini into my build.
Unfortunately, I’m having issues with the escaping of my WiFi password:
The password looks like #blaBla\lol%Hi (not my real password, obs).
Interestingly, the # is interpreted as a comment start, so I have to escape it with a \ backslash. This seems to kind of change the way the rest is being read, because then I also need to escape the % by adding another % in front of it. But there seems to be no way to escape the \. No matter how many \ I add before it, they are all being ignored.
wifi_ssid = myssid
wifi_pass = \#blaBla\\\lol%%Hi
platform = espressif32
board = esp32cam
framework = arduino
monitor_speed = 115200
description = take pictures and upload them to the web
build_flags are intended for the C-preprocessor but there is an additional layer of interpretation by the PIO commands and setup tools. So I suggest to use just numbers and letters which give 36 symbols to play with.
But, in my opinion, it is risky to put plain text passwords in development files. If you are not going on the internet, there is an ESP32 option called ESPNOW which uses MAC addresses of local devices. That worked for me.
What I’m looking for is some way of defining environment variables somewhere where it’s easy to exclude from version control (like an .env file) and including the values at compile time.
Changing the password is unfortunately not an option (and generally the method should better work with any password without having to escape stuff).
Maybe I should just write some header and include it?