ESP 8266 NodeMCU 1.0 (ESP-12E Module) won't load.

Being bored I started digging out some older projects I never managed to get working. The one which has me against the wall is this one. I have a NodeMCU 1.0 (ESP-12E Module) which using my Arduino IDE Ver 1.8.12 I can run simple things on like blink and basic programs but as soon as I start using libraries as in this example I get errors. So here is a code sample taken directly from examples. Hopefully someone else has a solution in addition to what I have tried and Google.

/*********
  Rui Santos
  Complete project details at https://randomnerdtutorials.com  
*********/

// Import required libraries
#include "WiFi.h"
#include "ESPAsyncWebServer.h"
#include <Adafruit_Sensor.h>
#include <DHT.h>

// Replace with your network credentials
const char* ssid = "MyNet";
const char* password = "MyPassword";

#define DHTPIN 27     // Digital pin connected to the DHT sensor
#define TCP_MSS 
#define LWIP_IPV6
#define LWIP_FEATURES 
#define LWIP_OPEN_SRC 

// Uncomment the type of sensor in use:
//#define DHTTYPE    DHT11     // DHT 11
#define DHTTYPE    DHT22     // DHT 22 (AM2302)
//#define DHTTYPE    DHT21     // DHT 21 (AM2301)

DHT dht(DHTPIN, DHTTYPE);

// Create AsyncWebServer object on port 80
AsyncWebServer server(80);

String readDHTTemperature() {
  // Sensor readings may also be up to 2 seconds 'old' (its a very slow sensor)
  // Read temperature as Celsius (the default)
  float t = dht.readTemperature();
  // Read temperature as Fahrenheit (isFahrenheit = true)
  //float t = dht.readTemperature(true);
  // Check if any reads failed and exit early (to try again).
  if (isnan(t)) {    
    Serial.println("Failed to read from DHT sensor!");
    return "--";
  }
  else {
    Serial.println(t);
    return String(t);
  }
}

String readDHTHumidity() {
  // Sensor readings may also be up to 2 seconds 'old' (its a very slow sensor)
  float h = dht.readHumidity();
  if (isnan(h)) {
    Serial.println("Failed to read from DHT sensor!");
    return "--";
  }
  else {
    Serial.println(h);
    return String(h);
  }
}

const char index_html[] PROGMEM = R"rawliteral(
<!DOCTYPE HTML><html>
<head>
  <meta name="viewport" content="width=device-width, initial-scale=1">
  <link rel="stylesheet" href="https://use.fontawesome.com/releases/v5.7.2/css/all.css" integrity="sha384-fnmOCqbTlWIlj8LyTjo7mOUStjsKC4pOpQbqyi7RrhN7udi9RwhKkMHpvLbHG9Sr" crossorigin="anonymous">
  <style>
    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; }
    .dht-labels{
      font-size: 1.5rem;
      vertical-align:middle;
      padding-bottom: 15px;
    }
  </style>
</head>
<body>
  <h2>ESP32 DHT Server</h2>
  <p>
    <i class="fas fa-thermometer-half" style="color:#059e8a;"></i> 
    <span class="dht-labels">Temperature</span> 
    <span id="temperature">%TEMPERATURE%</span>
    <sup class="units">&deg;C</sup>
  </p>
  <p>
    <i class="fas fa-tint" style="color:#00add6;"></i> 
    <span class="dht-labels">Humidity</span>
    <span id="humidity">%HUMIDITY%</span>
    <sup class="units">%</sup>
  </p>
</body>
<script>
setInterval(function ( ) {
  var xhttp = new XMLHttpRequest();
  xhttp.onreadystatechange = function() {
    if (this.readyState == 4 && this.status == 200) {
      document.getElementById("temperature").innerHTML = this.responseText;
    }
  };
  xhttp.open("GET", "/temperature", true);
  xhttp.send();
}, 10000 ) ;

setInterval(function ( ) {
  var xhttp = new XMLHttpRequest();
  xhttp.onreadystatechange = function() {
    if (this.readyState == 4 && this.status == 200) {
      document.getElementById("humidity").innerHTML = this.responseText;
    }
  };
  xhttp.open("GET", "/humidity", true);
  xhttp.send();
}, 10000 ) ;
</script>
</html>)rawliteral";

// Replaces placeholder with DHT values
String processor(const String& var){
  //Serial.println(var);
  if(var == "TEMPERATURE"){
    return readDHTTemperature();
  }
  else if(var == "HUMIDITY"){
    return readDHTHumidity();
  }
  return String();
}

void setup(){
  // Serial port for debugging purposes
  Serial.begin(115200);

  dht.begin();
  
  // Connect to Wi-Fi
  WiFi.begin(ssid, password);
  while (WiFi.status() != WL_CONNECTED) {
    delay(1000);
    Serial.println("Connecting to WiFi..");
  }

  // Print ESP32 Local IP Address
  Serial.println(WiFi.localIP());

  // Route for root / web page
  server.on("/", HTTP_GET, [](AsyncWebServerRequest *request){
    request->send_P(200, "text/html", index_html, processor);
  });
  server.on("/temperature", HTTP_GET, [](AsyncWebServerRequest *request){
    request->send_P(200, "text/plain", readDHTTemperature().c_str());
  });
  server.on("/humidity", HTTP_GET, [](AsyncWebServerRequest *request){
    request->send_P(200, "text/plain", readDHTHumidity().c_str());
  });

  // Start server
  server.begin();
}
 
void loop(){
  
}

To be continued

Thanks
Ron

Continuation:

Now here are the errors. Always the same when these libraries are used or called.

Arduino: 1.8.12 (Windows 10), Board: "NodeMCU 1.0 (ESP-12E Module), 80 MHz, Flash, Legacy (new can return nullptr), All SSL ciphers (most compatible), 4MB (FS:2MB OTA:~1019KB), 2, v2 Lower Memory, Disabled, None, Only Sketch, 115200"

In file included from C:\Users\ron\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.6.3/tools/sdk/lwip2/include/lwip/opt.h:51:0,

from C:\Users\ron\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.6.3/tools/sdk/lwip2/include/lwip/init.h:40,

from C:\Users\ron\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.6.3\cores\esp8266/IPAddress.h:27,

from C:\Users\ron\Documents\Arduino\libraries\WiFi\src/WiFi.h:30,

from C:\Users\ron\Documents\Arduino\DHT_ESP\DHT_ESP.ino:7:

C:\Users\ron\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.6.3/tools/sdk/lwip2/include/lwipopts.h:1305:2: error: #error TCP_MSS must be defined

#error TCP_MSS must be defined

^

C:\Users\ron\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.6.3/tools/sdk/lwip2/include/lwipopts.h:2385:2: error: #error LWIP_IPV6 must be defined

#error LWIP_IPV6 must be defined

^

C:\Users\ron\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.6.3/tools/sdk/lwip2/include/lwipopts.h:3545:2: error: #error LWIP_FEATURES must be defined

#error LWIP_FEATURES must be defined

^

In file included from C:\Users\ron\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.6.3/tools/sdk/lwip2/include/glue.h:53:0,

from C:\Users\ron\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.6.3/tools/sdk/lwip2/include/arch/cc.h:61,

from C:\Users\ron\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.6.3/tools/sdk/lwip2/include/lwip/arch.h:48,

from C:\Users\ron\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.6.3/tools/sdk/lwip2/include/lwip/debug.h:40,

from C:\Users\ron\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.6.3/tools/sdk/lwip2/include/lwipopts.h:3602,

from C:\Users\ron\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.6.3/tools/sdk/lwip2/include/lwip/opt.h:51,

from C:\Users\ron\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.6.3/tools/sdk/lwip2/include/lwip/init.h:40,

from C:\Users\ron\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.6.3\cores\esp8266/IPAddress.h:27,

from C:\Users\ron\Documents\Arduino\libraries\WiFi\src/WiFi.h:30,

from C:\Users\ron\Documents\Arduino\DHT_ESP\DHT_ESP.ino:7:

C:\Users\ron\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.6.3/tools/sdk/include/user_interface.h:34:2: error: #error LWIP_OPEN_SRC must be defined

#error LWIP_OPEN_SRC must be defined

^

Multiple libraries were found for "DHT.h"
Used: C:\Users\ron\Documents\Arduino\libraries\DHT-sensor-library-master
Not used: C:\Users\ron\Documents\Arduino\libraries\DHT_sensor_library
Not used: C:\Users\ron\Documents\Arduino\libraries\DHT_sensor_library-1.3.8
Not used: C:\Users\ron\Documents\Arduino\libraries\DHT_sensor
Multiple libraries were found for "WiFi.h"
Used: C:\Users\ron\Documents\Arduino\libraries\WiFi
Not used: C:\Program Files (x86)\Arduino\libraries\WiFi
exit status 1
Error compiling for board NodeMCU 1.0 (ESP-12E Module).

This report would have more information with
"Show verbose output during compilation"
option enabled in File -> Preferences.

I have removed and replaced the libraries numerous times. The addition of define for the problem areas was apparently a fix for early versions of the IDE. All of the files in C:\Users\ron\AppData\Local\Arduino15 have been removed and replaced with fresh downloads. The board I am using is the same board I choose in tools/board. Again I can load simple blink and similar programs no problem at all. The DHT modules are known good and actually I have tried more than one module with the same results. It always comes down to the same errors. Has anyone else ran into the same errors? Every now and then I drag this out and try again and kick it around for a few days. Obviously I am missing something in all of this.

Thank You
Ron

You're using the incorrect library. You are using the normal arduino library for WIFI, but you should be using ESP8266WiFi.h instead.

Seems there may also be an issue with DHT.h - there are four versions of the library you have installed, which may cause conflicts. Delete the ones you aren't using if it's an issue after you change your wifi import.

Thank you ever so much. I will try different library and yes, every time I get errors it goes back to libraries. I had a feeling about this. Again, want to thank you for pointing this out. Next day or two I'll have to try changing a few things.

Ron