title: How to pass a variable to wifiManager.autoConnect() to name the AP
body: <p>I am trying to get my ESP8266 to set the AP name to <code>Stand</code> + the MAC address minus the semicolons, like <code>Stand5CCF7F238734</code>.</p>
  
  <p>The <code>GetMyMacAddress()</code> function I wrote is clearly working, the serial output shows that.</p>
  
  <p>Every time I try to pass a String or char variable to <code>wifiManager.autoConnect()</code> I get compiler errors. Even though the header file identifies String type.</p>
  
  <p>If I pass <code>macStr</code> or <code>*macStr</code></p>
  
  <blockquote>
    <p>invalid conversion from 'char' to 'const char*' [-fpermissive]</p>
  </blockquote>
  
  <p>If I pass <code>ap2</code> (String type) I get:</p>
  
  <blockquote>
    <p>no matching function for call to 'WiFiManager::autoConnect(String&amp;)'</p>
  </blockquote>
  
  <p>My code:</p>
  
  <pre class="lang-cpp prettyprint-override"><code>#include &lt;ESP8266WiFi.h&gt;
  #include &lt;DNSServer.h&gt;
  #include &lt;ESP8266WebServer.h&gt;
  #include &lt;WiFiManager.h&gt;
  
  String ap = "Stand";
  String ap2;
  uint8_t mac[6];
  char const macStr[19] = {0};
  
  void setup() {
      Serial.begin(115200);
      WiFiManager wifiManager;  //WiFiManager -- Local intialization.
  
      ap2 = ap + GetMyMacAddress();
  
      //std::string ap2;
      char *macStr = new char[ap2.length()+ 1 ];
      strcpy(macStr, ap2.c_str());
  
      //fetches ssid and pass from eeprom and tries to connect
      //if connect fails it starts an access point with the specified name
      //here  "AutoConnectAP" and goes into a loop awaiting configuration
  
      wifiManager.autoConnect( "Stand" );
      //or use this for auto generated name ESP + ChipID
      //wifiManager.autoConnect();
  
      //if you get here you have connected to the WiFi
      Serial.println("connected...yeey :)");
      Serial.print("ap2"); Serial.print("    " ); Serial.print( ap2); Serial.println(" String");
      Serial.print("macStr"); Serial.print(" "); Serial.print( macStr ); Serial.println(" Char");
  }
  
  void loop() {
  }
  
  String GetMyMacAddress()
  {
    uint8_t mac[6];
    char macStr[18] = {0};
    WiFi.macAddress(mac);
    sprintf(macStr, "%02X%02X%02X%02X%02X%02X", mac[0],  mac[1], mac[2], mac[3], mac[4], mac[5]); // no :'s
    // sprintf(macStr, "%02X:%02X:%02X:%02X:%02X:%02X", mac[0],  mac[1], mac[2], mac[3], mac[4], mac[5]);  // with :'s
    return  String(macStr);
  }
  </code></pre>
  
  <p>When connected, the serial outputs:</p>
  
  <pre><code>connected...yeey :)
  ap2    Stand5CCF7F238734 String
  macStr Stand5CCF7F238734 Char
  </code></pre>