I have looked up this error and the most common answer is that I need to flash my NodeMCU ESP8266. I thought I've already done that and the only issue with the problem being that my ESP8266 might not be flashed is that this error only shows when I change a certain line of code.
As of right now, I'm messing around with code that allows me to turn an LED on or off through the web. What I'm trying to do is add a blink to it, I have two tabs one of which has the blinking code(Blink.h) and the other has the main code (AP_Simple_12e_WITH_BLINK). The error shows up when I use #include later in the code. If I remove the line saying "#include <Blink.h>;" (Under the comment // Match the Request) I don't get the error and it compiles with no issue.
I know that you can't use two loops in one program so I'm kinda out of ideas on what to do. The goto doesn't allow you to jump to another Tab, and the only reason I used another tab was to make the code neat and readable. I understand that the goto is bad to use but since I can't use another loop function and me being so new to this I need some help.
The reason there is a digitalWrite right above the #include was for me to see if it was the placement of
the code around the #include that was causing the issue. (from my understanding, it isnt)
#include <ESP8266WiFi.h>
const char* ssid = "Pool Wifi";
const char* password = "arduino";
int ledPin = 13; // GPIO13
WiFiServer server(80);
void setup() {
Serial.begin(115200);
delay(10);
pinMode(ledPin, OUTPUT);
digitalWrite(ledPin, LOW);
// Connect to WiFi network
Serial.println();
Serial.println();
Serial.print("Connecting to ");
Serial.println(ssid);
WiFi.begin(ssid, password);
while (WiFi.status() != WL_CONNECTED) {
delay(500);
Serial.print(".");
}
Serial.println("");
Serial.println("WiFi connected");
// Start the server
server.begin();
Serial.println("Server started");
// Print the IP address
Serial.print("Use this URL to connect: ");
Serial.print("http://");
Serial.print(WiFi.localIP());
Serial.println("/");
}
void loop() {
// Check if a client has connected
WiFiClient client = server.available();
if (!client) {
return;
}
// Wait until the client sends some data
Serial.println("new client");
while(!client.available()){
delay(1);
}
// Read the first line of the request
String request = client.readStringUntil('\r');
Serial.println(request);
client.flush();
// Match the request
int value = LOW;
if (request.indexOf("/LED=ON") != -1) {
digitalWrite(ledPin, HIGH);
value = HIGH;
}
if (request.indexOf("/LED=OFF") != -1) {
digitalWrite(ledPin, LOW);
value = LOW;
}
if (request.indexOf("/LED=BLINK") != -1) {
digitalWrite(ledPin, HIGH);
#include <Blink.h>;
}
// Set ledPin according to the request
//digitalWrite(ledPin, value);
// Return the response
client.println("HTTP/1.1 200 OK");
client.println("Content-Type: text/html");
client.println(""); // do not forget this one
client.println("<!DOCTYPE HTML>");
client.println("<html>");
client.print("Led pin is now: ");
if(value == HIGH) {
client.print("On");
} else {
client.print("Off");
}
client.println("
");
client.println("<a href=\"/LED=ON\"\"><button>Turn On </button></a>");
client.println("<a href=\"/LED=OFF\"\"><button>Turn Off </button></a>
");
client.println("<a href=\"/LED=BLINK\"\"><button>Blink </button></a>");
client.println("</html>");
delay(.5);
Serial.println("Client disonnected");
Serial.println("");
}
Blinker:
digitalWrite(ledPin, LOW);
delay(500);
digitalWrite(ledPin, HIGH);
delay(500);
goto Blinker;
This is the error message I get, again only when I use the #include (probably where I'm not supposed to). I Can include the verbose version of the error if needed.
compilation terminated.
Using library ESP8266WiFi at version 1.0 in folder: C:\Users\milkj\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.3.0\libraries\ESP8266WiFi
exit status 1
Error compiling for board NodeMCU 1.0 (ESP-12E Module).