I have written this sketch, and I am trying to populate the array of wifi hotspots to set the value in html select using javascript dynamically.

#include <Arduino.h>
#include <Hash.h>
#include "ESP8266WiFi.h"
#include <ESPAsyncTCP.h>
#include <ESPAsyncWebServer.h>

const char* ap_ssid     = "ESP8266";
const char* ap_password = "0123456789";

// Create AsyncWebServer object on port 8080
AsyncWebServer ap_server(8080);

const char index_html[] PROGMEM = R"rawliteral(
  <meta name="viewport" content="width=device-width, initial-scale=1">
    html {
     font-family: Arial;
     display: inline-block;
     margin: 0px auto;
     text-align: center;
    h2 { font-size: 3.0rem; }
    p { font-size: 3.0rem; }
    .units { font-size: 1.2rem; }
      font-size: 1.5rem;
      padding-bottom: 15px;
  var select = document.getElementById("wifi");
  hotspots = %wifi_networks%;
  for(index in hotspots) {
      select.options[select.options.length] = new Option(hotspots[index], index);
  <h2>Connect to a Wifi Networks</h2>
    <form action="#">
  <label for="wifi">Choose a hotspot to connect:</label>
  <select name="wifi" id="wifi">
    <option value="volvo">None</option>
  <label for="wifi">Enter password:</label>
  <input type="text"></input>
  <input type="rescan" value="Rescan">
  <input type="submit" value="Connect">


void setup() {
  Serial.print("Setting AP (Access Point)…");
  // Remove the password parameter, if you want the AP (Access Point) to be open
  WiFi.softAP(ap_ssid, ap_password);

  IPAddress IP = WiFi.softAPIP();
  Serial.print("AP IP address: ");

  // Print ESP8266 Local IP Address

  // Route for root / web page
  ap_server.on("/", HTTP_GET, [](AsyncWebServerRequest * request) {
    request->send_P(200, "text/html", index_html, getWifiHotspots());

  // Start server

void loop() {
  // put your main code here, to run repeatedly:


But I am geting this error

    /Arduino/libraries/ESPAsyncWebServer/src/ESPAsyncWebServer.h:243:10: error:   initializing argument 4 of 'void AsyncWebServerRequest::send_P(int, const String&, const uint8_t*, size_t, AwsTemplateProcessor)' [-fpermissive]

     void send_P(int code, const String& contentType, const uint8_t * content, size_t len, 
AwsTemplateProcessor callback=nullptr);

exit status 1
invalid conversion from 'const char*' to 'const uint8_t* {aka const unsigned char*}' [-fpermissive]
  • Try to force the conversion in the function parameter: send_P(200, "text/html", (uint8_t *)index_html, getWifiHotspots());.
    – JSC
    Commented May 24, 2020 at 21:05

1 Answer 1


In the library ESPAsyncWebServer.h are these two possible function variants defined

  void send_P(int code, const String& contentType, const uint8_t * content, size_t len, AwsTemplateProcessor callback=nullptr);
   void send_P(int code, const String& contentType, PGM_P content, AwsTemplateProcessor callback=nullptr);

So when using

const char index_html[] PROGMEM = R"rawliteral(<YOUR HTML here>)rawliteral";

give the compiler the explicit instruction

ap_server.on("/", HTTP_GET, [](AsyncWebServerRequest * request) {
  request->send_P(200, "text/html", (const uint8_t*) index_html, getWifiHotspots());

The code compiles error free on ArduinoIDE 1.8.12/ESP8266 2.71/ NodeMCUv1 (as not having your definition of getWifiHotspots() I defined it as char)

  • I see, I am getting error because index_html is of char type and the getWifiHotspots returns array of Strings? Commented May 24, 2020 at 21:16
  • @Ciastopiekarz No, as the error message clearly states, the argument is a const char *, and the function expects a const uint8_t *. -- BTW, actually you are programming C++, and the right cast is static_cast<const uint8_t *>(...). Commented May 25, 2020 at 6:16

Your Answer

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

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