4

I'm trying to upload the code from here to work with an ESP8266. So I copy/pasted the code to the Arduino IDE and I get this error:

C:\Program Files (x86)\Arduino\libraries\WiFi\src/WiFi.h:79:9: error: initializing argument 1 of 'int WiFiClass::begin(char*, const char*)' [-fpermissive]

int begin(char* ssid, const char *passphrase); ^

exit status 1 invalid conversion from 'const char*' to 'char*' [-fpermissive]

Can anyone help me with this?

per1234
  • 4,278
  • 2
  • 24
  • 43
Physther
  • 207
  • 2
  • 4
  • 8

2 Answers2

4

This begin() method expects a modifiable character array as its first argument. That's what you should provide:

char ssid[]           = "YOUR_SSID";      // this is changed
const char* password  = "YOUR_PASSWORD";  // this is fine
[...]
WiFi.begin(ssid, password);
Edgar Bonet
  • 45,094
  • 4
  • 42
  • 81
3

The location where you are calling the function begin, has as first parameter a parameter of type const char* instead of char* ... remove the const from this argument type.

Probably you have something like

const char* s = ....

...

...begin(s, ...)

Change class s to

char* s = ...
Michel Keijzers
  • 13,014
  • 7
  • 41
  • 58