Adafruit ESP32 Calling WiFi101 When it Should Only Be Calling ESP32 WiFi Library

Hi folks, long time lurker, first time poster.

I’ve been trying to compile the following code (see below, I tried to remove as much as possible without removing anything that could be relevant) but have been running into the dreaded “trying to use WiFi101 with a non AVR board” error (also see below). This error makes sense as the ESP32 isn’t an AVR board. However, the error message states that the compiler was not using the WiFi101 library since it was correctly calling the ESP32 WiFi library. Why would it call code from the WiFi101 library then?

The abridged code:

// Run on Adafruit ESP32 Feather
// Libraries --------------------------------------------------------------------------------------
#include <WiFi.h>
#include <WebServer.h>
#include <SPI.h>
#include <SD.h>
#include "FS.h"

// Variables ---------------------------------------------------------------------------------------

// SPI Variables, removed for brevity

// SD Card Variables

// WiFi Variables
char ssid[] = "DragRake";         // Network Name
char pass[] = "";                 // Network password
String XML_values;                // XML data structure

int status = WL_IDLE_STATUS;
IPAddress local_ip(4,20,6,9);
IPAddress gateway(192,168,1,1);
IPAddress subnet(255,255,255,0);

// Set web server port number to 80 (Change if needed)
WebServer server(80);

// SPI configurations
SPISettings sensors(1000000, MSBFIRST, SPI_MODE0); //Both sensors are logic state low

// Setup -------------------------------------------------------------------------------------------------------
void setup()
{

  Serial.begin(115200);

  SPI.begin(); // moved ahead of setting up wifi, makes a difference?

  // Starting WiFi Network
  WiFi.softAP(ssid);
  WiFi.softAPConfig(local_ip, gateway, subnet);

  // Initializing webpages
  server.on("/", handle_read(0));
  server.on("/read1", handle_read(1));
  server.on("/update", handle_update);
  server.onNotFound(handle_NotFound);

  server.begin();

  // Initializing Sd card interface
  // Creating unique file name to avoid overwriting existing files

}

// Loop --------------------------------------------------------------------------------------------------------
void loop()
{
  // Uses SPI to take measurements from sensors, removed since not relevant
  // Webpage stuff
  server.handleClient();

// Functions -------------------------------------------------------------------------------------------


void handle_read(int mode) {
  // print mode
  server.send(200, "text/html", SendHTML(mode)); 
}

void handle_NotFound() {
  server.send(404, "text/plain", "Not found");
}

void handle_update() {
  // XML values to send data to webpage

  server.send(200, "text/plain", XML_values);
}

String SendHTML(int mode)
{
  //HTML Setup Stuff
  String ptr = "<!DOCTYPE html> <html>\n";
  ptr +="<head><meta name=\"viewport\" content=\"width=device-width, initial-scale=1.0, user-scalable=no\">\n";
  ptr +="<title>Drag Rake Controls</title>\n";
  ptr +="<style>html { font-family: Helvetica; display: inline-block; margin: 0px auto; text-align: left;}\n";
// HTML styling removed

  ptr +="</style>\n";
  ptr +="</head>\n";
  ptr +="<body>\n";

  // Title
  ptr +="<div>";
  ptr +="<h1>Drag Rake</h1>\n";
  ptr +="<h3>Akaflieg SLO ESP32 Proto-build</h3>\n";
  ptr +="<!-- EASTER EGG -->";

  // Data displays
  ptr +=("<h2><input class=\"read upp\" id=\"Upper\" value=\"0\"/>Upper Surface &Delta;Pressure (Pa)</h2>";
  ptr +="<h2><input class=\"read low\" id=\"Lower\" value=\"0\"/>Lower Surface &Delta;Pressure (Pa)</h2>";
  ptr +="<h2><input class=\"read avg\"id=\"Average\" value=\"0\"/>Average &Delta;Pressure (Pa)</h2>";
  ptr +="<h2><input class=\"read batt\"id=\"Battery\" value=\"0\"/>Battery Remaining (%)</h2>";
  ptr +="</div>";

  // Buttons
  ptr +="<div>";
  ptr +="<h3>Sensor Read Modes</h3>\n";
  switch (mode)
  {
    case 0:
    ptr +="<a class=\"button button-off\" href=\"/\">OFF</a>";
    ptr +="<a class=\"button button-on\" href=\"/read1\">ON</a>";
    ptr +="<a class=\"button button-on\" href=\"/read2\">ON</a>\n";
    ptr +="<a class=\"button button-on\" href=\"/read4\">ON</a>";
    ptr +="<a class=\"button button-on\" href=\"/read8\">ON</a>";
    ptr +="<a class=\"button button-on\" href=\"/read16\">ON</a>\n";
    break;
  // other cases removed for brevity
  }
  ptr +="</div>";

  // AJAX Script (move to top of document if possible just for organization)
  ptr = "<script>";
  ptr = "setInterval(function() {"; // Call a function repetatively with 2 Second interval
  ptr = "getData();}, 200);"; // 200 millis update rate
  ptr = "function getData() {";
  ptr = "var xhttp = new XMLHttpRequest();";
  ptr = "xhttp.onreadystatechange = function() {";
  ptr = "  if (this.readyState == 4 && this.status == 200) {";
  ptr = "   document.getElementById(\"Upper\").value =this.responseXML.getElementsByTagName('upper')[0].childNodes[0].nodeValue;";
  ptr = "   document.getElementById(\"Lower\").value =this.responseXML.getElementsByTagName('lower')[0].childNodes[0].nodeValue;";
  ptr = "   document.getElementById(\"Average\").value =this.responseXML.getElementsByTagName('average')[0].childNodes[0].nodeValue;";
  ptr = "   document.getElementById(\"Battery\").value =this.responseXML.getElementsByTagName('battery')[0].childNodes[0].nodeValue;";
  ptr = "  }";
  ptr = "};";
  ptr = "xhttp.open("GET", "update", true);";
  ptr = "xhttp.send();";
  ptr = "}";
  ptr = "</script>";

  ptr +="</body>\n";
  ptr +="</html>\n";
  return ptr; 
}

The WiFi101 error message:

Arduino: 1.8.13 (Mac OS X), Board: "Adafruit ESP32 Feather, 80MHz, 921600, None, Default"

/Users/Bennett/Documents/Arduino/libraries/WiFi101/src/WiFiMDNSResponder.cpp:24:26: fatal error: avr/pgmspace.h: No such file or directory
Multiple libraries were found for "WiFi.h"
compilation terminated.
 Used: /Users/Bennett/Library/Arduino15/packages/esp32/hardware/esp32/1.0.4/libraries/WiFi
 Not used: /Applications/Arduino.app/Contents/Java/libraries/WiFi
Multiple libraries were found for "SD.h"
 Used: /Users/Bennett/Library/Arduino15/packages/esp32/hardware/esp32/1.0.4/libraries/SD
 Not used: /Applications/Arduino.app/Contents/Java/libraries/SD
exit status 1
Error compiling for board Adafruit ESP32 Feather.

If I remove the WiFi101 library from the arduino filepath, I get this cryptic error (see below), but google yields nothing.

Arduino: 1.8.13 (Mac OS X), Board: "Adafruit ESP32 Feather, 80MHz, 921600, None, Default"

sketch/the up to date code from SPI.cpp:9:21: fatal error: WiFi101.h: No such file or directory
compilation terminated.
Multiple libraries were found for "WiFi.h"
 Used: /Users/Bennett/Library/Arduino15/packages/esp32/hardware/esp32/1.0.4/libraries/WiFi
 Not used: /Applications/Arduino.app/Contents/Java/libraries/WiFi
Multiple libraries were found for "SD.h"
 Used: /Users/Bennett/Library/Arduino15/packages/esp32/hardware/esp32/1.0.4/libraries/SD
 Not used: /Applications/Arduino.app/Contents/Java/libraries/SD
exit status 1
Error compiling for board Adafruit ESP32 Feather.

Any insights are greatly appreciated, thank you!

reinstall the esp32 boards package. you have some invalid changes there

It works! Thank you so much!