Unmodified 'Examples' ESP WiFi sketches compile error

I get similar errors on other ESP32 Example WiFi sketches. Is this a screwed up library issue possibly?
ESP/espressif software library installed in Library Mgr as well as github json link in Preferences.

IDE 1.8.19/ Ubuntu Linux 20.04 LTS

t#include <WiFiLink.h>


char ssid[] = "xxxxxxxxxxx";      // your network SSID (name)
char pass[] = "xxxxxxxxxx";   // your network password
int keyIndex = 0;                 // your network key Index number (needed only for WEP)

int status = WL_IDLE_STATUS;

WiFiServer server(80);

void setup() {
  //Initialize serial and wait for port to open:
  Serial.begin(115200);
  while (!Serial) {
    ; // wait for serial port to connect. Needed for native USB port only
  }

WiFiWebServer:31:12: error: cannot declare variable 'server' to be of abstract type 'WiFiServer'
 WiFiServer server(80);
            ^~~~~~
In file included from /home/ed/Arduino/libraries/WiFi_Link/src/WiFiLink.h:38,
                 from /tmp/arduino_modified_sketch_592500/WiFiWebServer.ino:22:
/home/ed/Arduino/libraries/WiFi_Link/src/WiFiServer.h:31:7: note:   because the following virtual functions are pure within 'WiFiServer':
 class WiFiServer : public Server {
       ^~~~~~~~~~
In file included from /home/ed/.arduino15/packages/esp32/hardware/esp32/2.0.2/cores/esp32/Arduino.h:165,
                 from /tmp/arduino_build_890735/sketch/WiFiWebServer.ino.cpp:1:
/home/ed/.arduino15/packages/esp32/hardware/esp32/2.0.2/cores/esp32/Server.h:28:18: note: 	'virtual void Server::begin(uint16_t)'
     virtual void begin(uint16_t port=0) =0;
                  ^~~~~
Using library WiFi_Link at version 1.0.1 in folder: /home/ed/Arduino/libraries/WiFi_Link 
exit status 1
cannot declare variable 'server' to be of abstract type 'WiFiServer'

Is the SSID of the router at your home really "xxxxxxxxxxx" ?

Is it's password really "xxxxxxxxxxx" ?

The comment "// your network SSID (name)" is a reminder that you have to insert the appropriate values in place of the x's.

Don

Its a habit to remove that type of info in a public post. I did have the correct data on the compile.

Your title says "Unmodified" so I thought you may have actually used those values.

Don

i'm a newbie but not that newbie...lol

1 Like

I haven't used that library before... the ESP32 WiFi example sketches in my IDE use these

#include <WiFi.h>
#include <WiFiClient.h>
#include <WebServer.h>

Does this example work...

#include <WiFi.h>
#include <WiFiClient.h>
#include <WebServer.h>
#include <ESPmDNS.h>

const char* ssid = "........";
const char* password = "........";

WebServer server(80);

const int led = 13;

void handleRoot() {
  digitalWrite(led, 1);
  server.send(200, "text/plain", "hello from esp32!");
  digitalWrite(led, 0);
}

void handleNotFound() {
  digitalWrite(led, 1);
  String message = "File Not Found\n\n";
  message += "URI: ";
  message += server.uri();
  message += "\nMethod: ";
  message += (server.method() == HTTP_GET) ? "GET" : "POST";
  message += "\nArguments: ";
  message += server.args();
  message += "\n";
  for (uint8_t i = 0; i < server.args(); i++) {
    message += " " + server.argName(i) + ": " + server.arg(i) + "\n";
  }
  server.send(404, "text/plain", message);
  digitalWrite(led, 0);
}

void setup(void) {
  pinMode(led, OUTPUT);
  digitalWrite(led, 0);
  Serial.begin(115200);
  WiFi.mode(WIFI_STA);
  WiFi.begin(ssid, password);
  Serial.println("");

  // Wait for connection
  while (WiFi.status() != WL_CONNECTED) {
    delay(500);
    Serial.print(".");
  }
  Serial.println("");
  Serial.print("Connected to ");
  Serial.println(ssid);
  Serial.print("IP address: ");
  Serial.println(WiFi.localIP());

  if (MDNS.begin("esp32")) {
    Serial.println("MDNS responder started");
  }

  server.on("/", handleRoot);

  server.on("/inline", []() {
    server.send(200, "text/plain", "this works as well");
  });

  server.onNotFound(handleNotFound);

  server.begin();
  Serial.println("HTTP server started");
}

void loop(void) {
  server.handleClient();
  delay(2);//allow the cpu to switch to other tasks
}

Are you sure you have the correct board selected?

I have tried several different board types w/ same result.

Did you try the sketch I posted?

These #includes were used with your example:

#include <WiFi.h>
#include <WiFiClient.h>
#include <WebServer.h>
#include <WiFiLink.h>
#include <ESPmDNS.h>

error report:

/tmp/arduino_modified_sketch_79363/WiFiWebServer.ino: In function 'void setup()':
WiFiWebServer:43:24: error: 'WL_NO_WIFI_MODULE_COMM' was not declared in this scope
   if (WiFi.status() == WL_NO_WIFI_MODULE_COMM) {
                        ^~~~~~~~~~~~~~~~~~~~~~
Multiple libraries were found for "WiFi.h"
 Used: /home/ed/.arduino15/packages/esp32/hardware/esp32/2.0.2/libraries/WiFi
 Not used: /home/ed/Arduino Install Point/arduino-1.8.19/libraries/WiFi
 Not used: /home/ed/Arduino/libraries/WiFiNINA

WITHOUT 'WifiLink.h' error report:

/tmp/arduino_modified_sketch_913224/WiFiWebServer.ino: In function 'void setup()':
WiFiWebServer:43:24: error: 'WL_NO_WIFI_MODULE_COMM' was not declared in this scope
   if (WiFi.status() == WL_NO_WIFI_MODULE_COMM) {
                        ^~~~~~~~~~~~~~~~~~~~~~
Multiple libraries were found for "WiFi.h"
 Used: /home/ed/.arduino15/packages/esp32/hardware/esp32/2.0.2/libraries/WiFi

Did you try the sketch I posted ? or just add the includes to your own code? (which you haven't actually posted in full - it's hard to debug anything with only part of the code).

Are you sure WiFiLink works with ESP boards? Why do you use that library?

"These #includes were used with your example:"
Yes, I used your example both with and without WifiLink.h
Full sketch code:

#include <WiFiLink.h>


char ssid[] = "yourNetwork";      // your network SSID (name)
char pass[] = "secretPassword";   // your network password
int keyIndex = 0;                 // your network key Index number (needed only for WEP)

int status = WL_IDLE_STATUS;

WiFiServer server(80);

void setup() {
  //Initialize serial and wait for port to open:
  Serial.begin(115200);
  while (!Serial) {
    ; // wait for serial port to connect. Needed for native USB port only
  }

  //Check if communication with wifi module has been established
  if (WiFi.status() == WL_NO_WIFI_MODULE_COMM) {
    Serial.println("Communication with WiFi module not established.");
    while (true); // don't continue:
  }

  // attempt to connect to Wifi network:
  while ( status != WL_CONNECTED) {
    Serial.print("Attempting to connect to SSID: ");
    Serial.println(ssid);
    // Connect to WPA/WPA2 network. Change this line if using open or WEP network:
    status = WiFi.begin(ssid, pass);

    // wait 10 seconds for connection:
    delay(10000);
  }
  server.begin();
  // you're connected now, so print out the status:
  printWifiStatus();
}


void loop() {
  // listen for incoming clients
  WiFiClient client = server.available();
  if (client) {
    Serial.println("new client");
    // an http request ends with a blank line
    boolean currentLineIsBlank = true;
    while (client.connected()) {
      if (client.available()) {
        char c = client.read();
        Serial.write(c);
        // if you've gotten to the end of the line (received a newline
        // character) and the line is blank, the http request has ended,
        // so you can send a reply
        if (c == '\n' && currentLineIsBlank) {
          // send a standard http response header
          client.println("HTTP/1.1 200 OK");
          client.println("Content-Type: text/html");
          client.println("Connection: close");  // the connection will be closed after completion of the response
          client.println("Refresh: 5");  // refresh the page automatically every 5 sec
          client.println();
          client.println("<!DOCTYPE HTML>");
          client.println("<html>");
          // output the value of each analog input pin
          for (int analogChannel = 0; analogChannel < 6; analogChannel++) {
            int sensorReading = analogRead(analogChannel);
            client.print("analog input ");
            client.print(analogChannel);
            client.print(" is ");
            client.print(sensorReading);
            client.println("<br />");
          }
          client.println("</html>");
          break;
        }
        if (c == '\n') {
          // you're starting a new line
          currentLineIsBlank = true;
        }
        else if (c != '\r') {
          // you've gotten a character on the current line
          currentLineIsBlank = false;
        }
      }
    }
    // give the web browser time to receive the data
    delay(1);

    // close the connection:
    client.stop();
    Serial.println("client disonnected");
  }
}


void printWifiStatus() {
  // print the SSID of the network you're attached to:
  Serial.print("SSID: ");
  Serial.println(WiFi.SSID());

  // print your WiFi shield's IP address:
  IPAddress ip = WiFi.localIP();
  Serial.print("IP Address: ");
  Serial.println(ip);

  // print the received signal strength:
  long rssi = WiFi.RSSI();
  Serial.print("signal strength (RSSI):");
  Serial.print(rssi);
  Serial.println(" dBm");
}

"Are you sure WiFiLink works with ESP boards? Why do you use that library?"

Took it from the 'Drone Workshop' guy on YouTube. Worked for him just fine but he was running IDE 1.8.13 IIRC and I'm using 1.8.19.

post a link to the video.

Around 27 minute mark he loads and demonstrates various WiFi sketches including Wifi Web Server.

I suspect that library is outdated.

If you use this library instead...

//#include <WiFiLink.h>
#include <WiFi.h>

and comment out this check... which you don't really need...

//  if (WiFi.status() == WL_NO_WIFI_MODULE_COMM) {
//    Serial.println("Communication with WiFi module not established.");
//    while (true); // don't continue:
//  }

Then it compiles fine...

I get the same result. This is frustrating with these library issues. I get compiler warnings about multiple wifi.h sources and hope things still work right. I have fresh installed IDE many times and would rather avoid that again but I am getting inceasingly proficient at doing it and making the Linux related adjustments to get things lined out correctly.
With the ESP32 the library files seem to be an ongoing issue from my perspective as a neophyte.

Thanks for guiding me along.... appreciate the assist... :+1:

You get the same result as me? or you still get compiler errors?

Sorry did not mean to be ambiguous. The Example sketch compiled fine. Unfortunately it is not detecting my LAN router and linking but that is a different challenge. I have another sketch that links up just fine so go figure.

Ok cool... that code you have may have other issues given it is quite old.

There are a lot of ESP32 example sketches, so if you can get those working there is probably one that is close to what you want, that you can play around with.

LOL...that code IS a decade old. Trial and error is my only option as I am not a language programmer/coder by any stretch of the imagination. I know just enuf to be dangerous with things like going 'root' in Linux terminal. Lol ....thanks again..

1 Like