2

Im working with node mcu ESP 8266 and trying to make it a webserver but keep encountering this problem.

   #include<ESP8266WiFi.h>
    WiFiClient client;
    WiFiServer server(80);
    void setup() 
    {
    Serial.begin(9600);
    WiFi.begin("network","password");
    while(WiFi.status()!= WL_CONNECTED)
    {
      delay(200);
      Serial.print("...");
    }
    Serial.println("NodeMCu is connected");
    server.begin();
    }
    void loop() 
    {
    client = server.available();
    if(client==1)
    {
       String request= client.readStringUntil("\n");
      Serial.println(request);
    }
    }
    ```

I'm getting this error :error: invalid conversion from 'const char*' to 'char' [-fpermissive]
   24 |    String request= client.readStringUntil("\n");
      |                                           ^~~~
      |                                           |
      |                                           const char*
3
  • 1
    Please copy the exact error message, including the line where the compiler finds the error. Also put your code in a code block (" {} " when editing).
    – StarCat
    Commented Nov 23, 2021 at 10:18
  • 5
    BTW, the problem is in the client.readStringUntil("\n"). The double quotes make the \n into a c-string (const char *), but it expects a single character (char). You can correct this by changing "\n" into (single quoted) '\n', which makes it into a single character.
    – StarCat
    Commented Nov 23, 2021 at 10:24
  • I assume this is "off-topic" because the bug is not specifically about the Arduino. Given OP's level of experience, they had no way to know that. I expect many other Arduino novices will encounter this same error and come here looking for an explanation. Is this really so off-topic?
    – Phil Hord
    Commented Nov 30, 2021 at 19:14

0

Browse other questions tagged or ask your own question.