Error for compiling board NODEMCU 1.0(ESP-12E module)

Hi

I get this error when compiling

Any ideas?

D:\Gdrive\NAS\Arduino\libraries\ESP8266WiFi\src\ESP8266WiFiAP.cpp:29:10: fatal error: LwipDhcpServer-NonOS.h: No such file or directory
Multiple libraries were found for "ESP8266WiFi.h"
29 | #include <LwipDhcpServer-NonOS.h>
Used: D:\Gdrive\NAS\Arduino\libraries\ESP8266WiFi
| ^~~~~~~~~~~~~~~~~~~~~~~~
Not used: C:\Users\john\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\3.0.2\libraries\ESP8266WiFi
compilation terminated.
exit status 1
Error compiling for board NodeMCU 1.0 (ESP-12E Module).

This is my code

//https://roboticadiy.com/esp8266-iot-live-sensor-data-plotter-to-web-page/
// Node MCU ESP8266 12E


#include <ESP8266WiFi.h>
#include <ESPAsyncWebServer.h>
#include "DHT.h"
#include <ESPAsyncTCP.h>



//WiFi
char ssid[] = "a";
char wifipass[] = "aaaaaaaa";


#define DHTPIN 4 // Digital pin 2 (GPIO 4) connected to the DHT sensor

// 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);

// current temperature & humidity, this will be updated in loop function
float t = 0.0;
float tf = 0.0;
float h = 0.0;

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

unsigned long previousMillis = 0; //stoe last time DHT was updated
const long interval = 1000; // Updates DHT readings every 1 seconds

//web page
const char index_html[] PROGMEM = R"webpage(
<!DOCTYPE HTML><html>
<head>
<meta name="viewport" content="width=device-width, initial-scale=1">
<script src="https://code.highcharts.com/8.0/highcharts.js"></script>
<style>
body {
min-width: 300px;
max-width: 800px;
height: 400px;
margin: 0 auto;
}
h2 {
font-family: Arial;
font-size: 2.5rem;
text-align: center;
}
</style>
</head>
<body>
<h2>ESP8266 Weather Station Chart</h2>
<div id="temperature-chart" class="container"></div>
<div id="fahrenheit-chart" class="container"></div>
<div id="humidity-chart" class="container"></div>
</body>
<script>
var chartT = new Highcharts.Chart({
chart:{ renderTo : 'temperature-chart' },
title: { text: 'Temperature in Degree Celsius' },
series: [{
showInLegend: false,
data: []
}],
plotOptions: {
line: { animation: false,
dataLabels: { enabled: true }
},
series: { color: '#059e8a' }
},
xAxis: { type: 'datetime',
dateTimeLabelFormats: { second: '%H:%M:%S' }
},
yAxis: {
title: { text: 'Temperature (Celsius)' }
},
credits: { enabled: false }
});
setInterval(function ( ) {
var xhttp = new XMLHttpRequest();
xhttp.onreadystatechange = function() {
if (this.readyState == 4 && this.status == 200) {
var x = (new Date()).getTime(),
y = parseFloat(this.responseText);
if(chartT.series[0].data.length > 50) {
chartT.series[0].addPoint([x, y], true, true, true);
} else {
chartT.series[0].addPoint([x, y], true, false, true);
}
}
};
xhttp.open("GET", "/temperature", true);
xhttp.send();
}, 1000 ) ;

var chartF = new Highcharts.Chart({
chart:{ renderTo:'fahrenheit-chart' },
title: { text: 'Temperature in Fahrenheit' },
series: [{
showInLegend: false,
data: []
}],
plotOptions: {
line: { animation: false,
dataLabels: { enabled: true }
}
},
xAxis: {
type: 'datetime',
dateTimeLabelFormats: { second: '%H:%M:%S' }
},
yAxis: {
title: { text: 'fahrenheit (F)' }
},
credits: { enabled: false }
});
setInterval(function ( ) {
var xhttp = new XMLHttpRequest();
xhttp.onreadystatechange = function() {
if (this.readyState == 4 && this.status == 200) {
var x = (new Date()).getTime(),
y = parseFloat(this.responseText);
//console.log(this.responseText);
if(chartF.series[0].data.length > 50) {
chartF.series[0].addPoint([x, y], true, true, true);
} else {
chartF.series[0].addPoint([x, y], true, false, true);
}
}
};
xhttp.open("GET", "/fahrenheit", true);
xhttp.send();
}, 1000 ) ;

var chartH = new Highcharts.Chart({
chart:{ renderTo:'humidity-chart' },
title: { text: 'Humidity (%)' },
series: [{
showInLegend: false,
data: []
}],
plotOptions: {
line: { animation: false,
dataLabels: { enabled: true }
},
series: { color: '#18009c' }
},
xAxis: {
type: 'datetime',
dateTimeLabelFormats: { second: '%H:%M:%S' }
},
yAxis: {
title: { text: 'Humidity (%)' }
},
credits: { enabled: false }
});
setInterval(function ( ) {
var xhttp = new XMLHttpRequest();
xhttp.onreadystatechange = function() {
if (this.readyState == 4 && this.status == 200) {
var x = (new Date()).getTime(),
y = parseFloat(this.responseText);
//console.log(this.responseText);
if(chartH.series[0].data.length > 50) {
chartH.series[0].addPoint([x, y], true, true, true);
} else {
chartH.series[0].addPoint([x, y], true, false, true);
}
}
};
xhttp.open("GET", "/humidity", true);
xhttp.send();
}, 1000 ) ;
</script>
</html>)webpage";

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


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

  // 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);
  });
  server.on("/temperature", HTTP_GET, [](AsyncWebServerRequest * request) {
    request->send_P(200, "text/plain", String(t).c_str());
  });
  server.on("/fahrenheit", HTTP_GET, [](AsyncWebServerRequest * request) {
    request->send_P(200, "text/plain", String(tf).c_str());
  });
  server.on("/humidity", HTTP_GET, [](AsyncWebServerRequest * request) {
    request->send_P(200, "text/plain", String(h).c_str());
  });

  // Start server
  server.begin();
  dht.begin();
}

void loop() {
  unsigned long currentMillis = millis();
  if (currentMillis - previousMillis >= interval) {
    // save the last time you updated the DHT values
    previousMillis = currentMillis;
    // Read temperature as Celsius (the default)
    float currentT = dht.readTemperature();

    // if temperature read failed, we don't want to change t value
    if (isnan(currentT)) {
      Serial.println("Failed to read from DHT sensor!");
      Serial.println(currentT);
    }
    else {
      t = currentT;
      Serial.println(t);
    }
    // Read temperature as Fahrenheit
    float currentTf = dht.readTemperature(true);
    // if temperature read failed, we don't want to change tf value
    if (isnan(currentTf)) {
      Serial.println("Failed to read from DHT sensor!");
    }
    else {
      tf = currentTf;
      Serial.println(tf);
    }


    // Read Humidity
    float currentH = dht.readHumidity();
    // if humidity read failed, we don't want to change h value
    if (isnan(currentH)) {
      Serial.println("Failed to read from DHT sensor!");
    }
    else {
      h = currentH;
      Serial.println(h);
    }
  }
}

Might want to delete your code segment in the post and format it in the IDE (^T, I think... it's also an option in edit) and re-post using the code '</>' option... There should be some indentation to the code... this is almost impossible to read...


Does D:\Gdrive\NAS\Arduino\libraries\ESP8266WiFi actually exist...

You can also turn on verbose in the preferences and it might be more specific...

:smiley_cat:

Hi
Thanks!

Code formatted.

Library exist, checked.

Hi,
I tested it here and got an error here: " WiFi.begin(ssid, password); "
" 'password' was not declared in this scope ".

After I changed it to : " WiFi.begin(ssid, wifipass); "

compiled without error.

1 Like

It looks like the version of ESP8266WiFi that you installed as a third-party library is not up to date and you should be using the version of ESP8266WiFi that came with the ESP8266 core. I would delete the directory:
D:\Gdrive\NAS\Arduino\libraries\ESP8266WiFi

1 Like

How much for your eyes?

Thanks!

I deleted library, and then it used default lib. Compiled now.

Thanks!

if your problem was solved, do a kindness to everyone on the forum, especially to those who helped you.

Write [Solved] before your topic title, so if someone searches and finds your topic, they'll know what the solution looks like.

And if it was solved by some help, please tick tick Solution box, the one that best describes your solution.

Of course

Wrong variable name did help @ruilviana
Also wrong library helped @johnwasser

Code is running now. Thanks!

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.