ESP8266 Page loading issue

when I want to go to the online HTML page on my computer (the HTML page of the esp8266), the HTML page keeps loading,
but on the serial monitor of the esp8266, it tells me this when I try to go to the HTML page:


--------------- CUT HERE FOR EXCEPTION DECODER ---------------

Exception (3):
epc1=0x4000bf64 epc2=0x00000000 epc3=0x402135a3 excvaddr=0x40246327 depc=0x00000000

>>>stack>>>

ctx: cont
sp: 3ffffd70 end: 3fffffd0 offset: 0150
3ffffec0:  40246327 0000014b 00000000 4020ab38  
3ffffed0:  3fffdad0 00000001 3ffe85d0 402034b1  
3ffffee0:  3fff04d4 014d014f 80000000 3ffee948  
3ffffef0:  3fffdad0 3ffee6d8 3ffef834 40201525  
3fffff00:  00000000 3ffee6d8 3ffee680 40203268  
3fffff10:  4010628d 00000000 00000000 003b003f  
3fffff20:  00000000 3ffee920 3ffe8604 3ffee920  
3fffff30:  00000000 0004178a 00000000 00000001  
3fffff40:  00041726 3ffee920 00000064 3ffee948  
3fffff50:  3fffdad0 3ffee6b4 3ffee680 40203ad6  
3fffff60:  00000000 00041726 2f9db22d 04bac427  
3fffff70:  00008000 000000ff 3ffe8604 3ffee948  
3fffff80:  00000000 00041726 00000064 3ffee948  
3fffff90:  3fffdad0 00000000 3ffee91c 40203c23  
3fffffa0:  3fffdad0 00000000 3ffee91c 3ffee948  
3fffffb0:  3fffdad0 00000000 3ffee91c 4020bd68  
3fffffc0:  feefeffe feefeffe 3fffdab0 40100f8d  
<<<stack<<<

The code am running:
main code:

#include "htmlpage1.h"
int ena = D8;
int in1 = D6;
int in2 = D7;
int in3 = D2;
int in4 = D3;
int enb = D4;
int sto = 1;
int speed1 = 0; 
int autodrive = 0;
const int trigPin = D0;
const int echoPin = D1;
String accessName ="robot"; 
const int changeStep = 20;// 20 is 20% every time button is pushed
int outPutValue = 40;// variable holding the light output vlaue (initial value) 40 means 40%
const int motorMinimumSpeed=20;

#define SOUND_VELOCITY 0.034
#define CM_TO_INCH 0.393701

long duration;
float distanceCm;
float distanceInch;

#include <ESP8266WiFi.h>
#include <WiFiClient.h>
#include <ESP8266WebServer.h>
#include <ESP8266mDNS.h>



#ifndef STASSID
#define STASSID "Ghassan_2.4G"
#define STAPSK  "7RBNicT$T"
#endif

const char *ssid = STASSID;
const char *password = STAPSK;

ESP8266WebServer server(80);

void handleRoot() {
String HTML_page = speed_control_page_part1; 
 
 HTML_page.concat(outPutValue);  
 HTML_page.concat(speed_control_page_part2);  
 HTML_page.concat(outPutValue);
 HTML_page.concat(speed_control_page_part3);

 
  server.send(200, "text/html", HTML_page);

}

void handleNotFound() {

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

}

void setup(void) {
  pinMode(ena, OUTPUT);
  pinMode(in1, OUTPUT);
  pinMode(in2, OUTPUT);
  pinMode(enb, OUTPUT);
  pinMode(in3, OUTPUT);
  pinMode(in4, OUTPUT);
  
  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(accessName)) {
    Serial.println("MDNS responder started");
  }

  server.on("/", handleRoot);
  server.on("/speed", HTTP_GET, handleMotorSpeed);  
  server.on("/stop", HTTP_GET, handleMotorBrake);
  server.on("/direction", HTTP_GET, handleMotorDirection);
  server.on("/right", HTTP_GET, handleMotorRight);    
  server.on("/right", HTTP_GET, handleAutoOn);        
  server.onNotFound(handleNotFound);
  server.begin();
  Serial.println("HTTP server started");

}

void loop(void) {
  
  server.handleClient();
  MDNS.update();
    speed1 = (outPutValue * 2.5);
  
    if((sto == 1)) {
     analogWrite(ena, speed1); 
     analogWrite(enb, speed1); 
  }

  delay(100);

  if((autodrive == 1)) {
      digitalWrite(trigPin, LOW);
  delayMicroseconds(2);
  // Sets the trigPin on HIGH state for 10 micro seconds
  digitalWrite(trigPin, HIGH);
  delayMicroseconds(10);
  digitalWrite(trigPin, LOW);
  
  // Reads the echoPin, returns the sound wave travel time in microseconds
  duration = pulseIn(echoPin, HIGH);
  
  // Calculate the distance
  distanceCm = duration * SOUND_VELOCITY/2;
  
  // Convert to inches
  distanceInch = distanceCm * CM_TO_INCH;
  
  // Prints the distance on the Serial Monitor
  Serial.print("Distance (cm): ");
  Serial.println(distanceCm);
  Serial.print("Distance (inch): ");
  Serial.println(distanceInch);
      delay(500);
  if((10.00 > distanceCm)) {
    digitalWrite(in1,HIGH);
    digitalWrite(in2,LOW);
    digitalWrite(in3,LOW);
    digitalWrite(in4,HIGH);
    Serial.print("rotate");
  }
  
  else {
    digitalWrite(in1,LOW);
    digitalWrite(in2,HIGH);
    digitalWrite(in3,LOW);
    digitalWrite(in4,HIGH);
    Serial.print("forawrd");
  }
  }
  
}

void handleMotorSpeed() {                                                                 
  if(server.arg("do") == "slower")
  {
    outPutValue -=changeStep;
    
      if(outPutValue < motorMinimumSpeed)
      {
        outPutValue = motorMinimumSpeed;
      }
  }else{
    outPutValue +=changeStep;   
     
      if(outPutValue > 100)
      {
        outPutValue =100;
      } 
  }

  handleRoot();
}//



void handleMotorBrake() {
  if(server.arg("do") == "START")
  {  
        sto = 1;
  }else{
        sto = 0;
        digitalWrite(in1,LOW);
        digitalWrite(in2,LOW);
        digitalWrite(in3,LOW);
        digitalWrite(in4,LOW);
  }
  handleRoot();
}//
void handleMotorDirection() {
  if(server.arg("dir") == "CW")
  {  
    digitalWrite(in1,HIGH);
    digitalWrite(in2,LOW);
    digitalWrite(in3,HIGH);
    digitalWrite(in4,LOW);      
  }else{
    digitalWrite(in1,LOW);
    digitalWrite(in2,HIGH);
    digitalWrite(in3,LOW);
    digitalWrite(in4,HIGH); 
  }
  handleRoot();
}//
void handleMotorRight() {
  if(server.arg("move") == "right")
  {  
    digitalWrite(in1,HIGH);
    digitalWrite(in2,LOW);
    digitalWrite(in3,LOW);
    digitalWrite(in4,HIGH);
  }else{
    digitalWrite(in1,LOW);
    digitalWrite(in2,HIGH);
    digitalWrite(in3,HIGH);
    digitalWrite(in4,LOW);
  }
  handleRoot();
}//
void handleAutoOn() {
  if(server.arg("car") == "on")
  {  
    autodrive = 1;   
      
  }else{
    autodrive = 0;  
  }
  handleRoot();
}//

The htmlpage1.h:

const char speed_control_page_part1[]  PROGMEM = R"robojaxSpeed1(
<!DOCTYPE html>
<html>
<head>
<title>Robot Control</title>
<meta name="viewport" content="width=device-width, initial-scale=1">
<style>
* {box-sizing: border-box}

.container {
  width: 100%;
  background-color: #ddd;
}

.skills {
  text-align: right;
  padding-top: 10px;
  padding-bottom: 10px;
  color: white;
}

.html {width: )robojaxSpeed1";




const char speed_control_page_part2[] PROGMEM = R"robojaxSpeed2(%; 
background-color: #f44336;}
.nextprev a.rj-right, .nextprev a.rj-left {
    background-color: #f44336;
    color: #ffffff;
    border-color: #f44336;
}
.nextprev a {
    font-size: 22px;
    border: 1px solid #cccccc;
}
.rj-right {
    float: right!important;
}
.rj-btn, .rj-button {
    border: none;
    display: inline-block;
    padding: 8px 16px;
    vertical-align: middle;
    overflow: hidden;
    text-decoration: none;
    color: inherit;
    background-color: inherit;
    text-align: center;
    cursor: pointer;
    white-space: nowrap;
}
</style>
</head>
<body>

<h1>Speed Control</h1>
<div class="container">
<div class="skills html">)robojaxSpeed2";



const char speed_control_page_part3[] PROGMEM = R"robojaxSpeed3(%</div>
</div>
<hr>
<div class="nextprev">
<a class="rj-left rj-btn" href="/speed?do=slower">< Slower</a>
<a class="rj-right rj-btn" href="/speed?do=faster">Faster ></a>
</div>

<hr>
<h2>Start/Stop</h2>
<div class="nextprev">
<a class="rj-left rj-btn" href="/stop?do=START">START</a>
<a class="rj-right rj-btn" href="/stop?do=STOP">STOP</a>
</div>

<hr>
<h2>Direction</h2>
<div class="nextprev">
<a class="rj-left rj-btn" href="/direction?dir=CW">BACKWARD</a>
<a class="rj-right rj-btn" href="/direction?dir=CCW">FORWARD</a>
<a class="rj-left rj-btn" href="/right?move=right">Right</a>
<a class="rj-right rj-btn" href="/right?move=left">Left</a>
</div>

<hr>
<h2>Right/left</h2>
<div class="nextprev">
</div>

<hr>
<h2>Right/left</h2>
<div class="nextprev">
<a class="rj-left rj-btn" href="/autocar?car=on">AutoDrive On</a>
<a class="rj-right rj-btn" href="/autocar?car=off">AutoDrive Off</a>
</div>

</body>
</html>)robojaxSpeed3";

I got a little of the code from a youtube video so it is not 100% by me.
Any help would be appreciated

There is something called exception decoder that works in combination with the older IDEs (not 2.x). You need to install it

I don't know how it works exactly as I have never used it but you can dump your exception in it and it will present you with a more human readable version of the exception.

You need to call the PROGMEM function to add a PROGMEM char * it to a String.

 HTML_page.concat(FPSTR(outPutValue));  

and i think it should be

static const char speed_control_page_part3[] PROGMEM = R"robojaxSpeed3(%</div>  // etc

where should i add this code?

Any of the const char * PROGMEM should be static, and all of them should be called using FPSTR()
check

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