I'm using the ESP8266WiFi library on a NodeMCU, running the arduino bootloader in the arduino software (Windows 10 app version).

I'm trying to load the SSID and password from SD-card (this part is successfull).

My problem this far is when i use the Wifi library it looks like this:

 Wifi.begin(const char*, const char*); 

Since it takes 2 const parameters i cannot change it later. Is there anyway i can add SSID and PASSWORD to my sketch without having to recompile it. (I have to send it to people who does not know how to compile and flash an arduino)

I'm not attached to the ESP8266WiFi library, i'm not attached to SD-card, other solutions are welcome.

SD-reader works as planned, WiFi works as planned with a static password and SSID.

2 Answers 2


The const keyword there does not force the data you call it to be constant, it only forbids certain assignments with the parameters inside that function but it's just superfluous in most cases. Meaning you can call it with input you got from serial or some other source (for ex. setup page accessible from hotspot->Store in EEPROM->Next boot connect to set WiFi AP). There's also a nice StackOverflow thread about this here and why it's not actually a good idea in many cases.

  • I've considered this, but i think the user is on a level here where connecting to a temp hotspot would be too advanced. I even think that downloading a configuration file to an SD card is on the edge of too advanced - Thats my problem. Though i think your reply gave me an idea on how to fix it. Let me just try it out and if it works you get the correct answer. Aug 15, 2017 at 9:06

The problem was not const char*, but bad conversion from string to char*.

Thing that lead me to believe it was the const char* was an unclear compiler message, and poor understanding of C++ data types.

but the correct answer was:

 ssid.toCharArray(ssidc, ssid.length());

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.