i tried to use an asynchronic webserver for a new project with friends using this tutorial. We want to run an FFT while also changing some settings via the webserver. Since the tutorial only put code in the setup() i thought it would be good for performance.

When i just copy paste the code it works pretty ok, but then i wanted to change everything into classes like a good boy. Now i get this error:

 In file included from sketch\webserver.cpp:2:0:
webserver.h:36:29: error: initializer-string for array of chars is too long [-fpermissive]
   const char index_html[] = R"rawliteral(
sketch\webserver.cpp: In constructor 'webserver::webserver()':
webserver.cpp:4:22: error: initializer-string for array of chars is too long [-fpermissive]
 webserver::webserver() {

I tried to search for a solution, but all the other problems with this type of error, didnt seem to fit with my problem.

This is the header file where the char string is declared

#ifndef webserver_h
#define webserver_h

#include "Arduino.h"
#include "ESPAsyncWebServer.h"
#include "AsyncTCP.h"
#include <WiFi.h>

class webserver {
  // Insert Private Variables And Functions
   // Replace with your network credentials
  const char* ssid     = "ESP32-Todesstern";
  const char* password = "CaptainHook";

  const char* PARAM_INPUT_1 = "input1";
  const char* PARAM_INPUT_2 = "input2";
  const char* PARAM_INPUT_3 = "input3";
  // Set web server port number to 80
  AsyncWebServer server(int port);
  // Variable to store the HTTP request
  String header;

  IPAddress IP;
  //WiFiClient client;

  //Insert Public Variables and Functions
  String music_state;

  const char index_html[] PROGMEM = R"rawliteral(
  <!DOCTYPE HTML><html><head>
    <title>ESP Input Form</title>
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <form action="/get">
      input1: <input type="text" name="input1">
      <input type="submit" value="Submit">
    <form action="/get">
      input2: <input type="text" name="input2">
      <input type="submit" value="Submit">
    <form action="/get">
      input3: <input type="text" name="input3">
      <input type="submit" value="Submit">

  void setup_server(AsyncWebServer server);

  void notFound(AsyncWebServerRequest *request);


Thanks for the Help,


  • I don't know why you're getting that exact message, but: const char *index_html PROGMEM = There's nothing ESP32 or Arduino specific in nature of the question or solution(s). For what you're trying to do it would probably make sense to have it be static (more so if you really want an array for some reason) and defined outside the class or maybe using the newer inline variable feature. Or both declared and defined outside the class.
    – timemage
    Feb 14 at 13:56

Please check the readme: https://github.com/me-no-dev/ESPAsyncWebServer#send-large-webpage-from-progmem

You probably have to declare it in progmem without rawliteral.

const​ ​char​ index_html[] PROGMEM = ​"​...​"​; ​//​ large char array, tested with 14k​ request->​send_P​(​200​, ​"​text/html​"​, index_html);

  • If you try compiling (on ESP32 or anything else for that matter) with or without PROGMEM, with or without a lot of material in the string literal, you'll see the same message.
    – timemage
    Feb 14 at 14:00

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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