.ino File with wifi password that includes a back slash

#1

I’m successfully flashing my .ino file to my Arudino, but it wasn’t connecting to wifi. I’m just getting messages that it’s trying to connect. I tried a different wifi network and it worked fine. I’m thinking now that there’s an issue with the wifi password:

// WiFi credentials.
const char* WIFI_SSID = "myssid";
const char* WIFI_PASS = "day19\hour";

Notice the back slash. I’m thinking this is the issue. Is there a way to use this network and password? I noticed that as I was updating the code in the Arduino CLI that the text changed color to black when I added the slash, so I’m thinking that has to be the problem.

#2

Given the WiFi password day19\hour

You will need to escape the slash character ( \ ) since that character itself signals that the character following it should be escaped:

const char* WIFI_PASS = "day19\\hour";

Note that, depending on the WiFi connection library you’re using, we’ve come across cases where it is necessary to ‘double-escape’ slashes in your connection settings. Some libraries may be unescaping values you set in your .ino files later in the application run. So if the method above doesn’t work, try this:

const char* WIFI_PASS = "day19\\\hour";

1 Like