HTTPd JS thermostat page

I want to have serverHandle() /tempUP and /tempDown for each time it is clicked. I believe a POST command is most reasonable but not sure how best to do it as my attempts have resulted in syntax errors (unexpected } [when it belonged there]). The problem is the quotes.

How can I escape all the quotes here, like on type=“text/javascript”? Also, how few lines can this possibly be? I don’t want a million strcat()s.

I intend to put this in one large char array and serve it via http.

Here is the HTML code in it’s native form.

<html><head><title>Thermostat v0.1</title> 
<style> 
.buttonBlue { 
background-color: #1010B0; 
color: white; 
font-size: 16px; 
} 
.buttonRed { 
background-color: #D01010; 
color: white; 
font-size: 16px; 
} 
</style></head>


<body> <script type="text/javascript">
var clicks = " tempSetting ";
var xhr = new XMLHttpRequest(); 
function clickDown() {
        clicks -= 1;      
        document.getElementById("clicksID").innerHTML = clicks;
xhr.open("POST", "/tempDown", true);
} ;
      
    function clickUp() {
        clicks += 1;     
        document.getElementById("clicksID").innerHTML = clicks;
   xhr.open("POST", "/tempUp", true);    
} ;

    </script>   
<button class="buttonBlue" type="button" onclick="clickDown()">Cooler</button>
   <button class="buttonRed" type="button" onclick="clickUp()">Warmer</button>
 <p><a id=clicksID>70</a>

</body></html>

Here is the code… it is a large sketch:

 #include <LiquidCrystal_I2C.h>
#include <Wire.h>
#include <SPI.h>
#include <EEPROM.h>
#include <avr/pgmspace.h>
#include <DallasTemperature.h>
#include <OneWire.h>

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


//***  Inits  **************************************
LiquidCrystal_I2C lcd(0x27, 16, 2);
ESP8266WebServer server(80);

//*** Temperature Sensor Inits ********************
// Data wire is plugged into port 2 on the Arduino
#define ONE_WIRE_BUS 2

// Setup a oneWire instance to communicate with any OneWire devices (not just Maxim/Dallas temperature ICs)
OneWire oneWire(ONE_WIRE_BUS);

// Pass our oneWire reference to Dallas Temperature.
DallasTemperature sensors(&oneWire);

//*** Declarations *********************************
const char* ssid = "JMR";
const char* password = "crystal2965";

int currentMM, currentHH;
int fanMode, HHOffset, MMOffset, cursorPosition = 0, menuIndex = 0, menuIDc, menuDepth = 0;
int millisPrior, subLoop, tempReadI, locked, seed, scheduleHH, scheduleMM, scheduleTemp, tempSetting, tempTemp, currentTemp, systemOnMS, systemPrev = 0;
int ntpOn;
int flasherA[5][7] = { 0 };
unsigned long menuStartMS, flasherL[5], tempMS, fanMS, msOn, fanOn, heatOn, coolOn;
char lcdMode;
char *currentBlock;
char *menuIDa = 0, *menuIDb;
//float tempRounded = 70.5;
String currentTimeStr, modeName;


// PIN-MAP
//*****************************************************************************************************************************************************************
// -1: InputPullup, 0: Not installed, 1: Input Positive, 2: OUTPUT
int installed[20] = {   0,  0,   2,      2,    2,     0,    2,    0,    0,     2,     2,     2,    1,      0,    1,     0,      0,    0,     0,          0 };
//char* pinNames[20] = { '0', '1', '2',   '3',   '4',   '5', '6', '7',   '8',   '9',  "10",  "11", "12",  "13",  "A0",  "A1",  "A2",  "A3",  "A4",      "A5"  };
//char* ssNames[20] = {  "x", "x", "FN6", "HT6", "AC6", "x", "LB6", "x", "x", "LO6", "LR6", "LG6",  "tm6", "LED",   "sd6", "x", "x", "x", "x", "x" };
const int                       FN6 = 2,     AC6 = 4,     LB6 = 6,                         LG6 = 11,     LED = 13,       sd6 = A0     ;
const int                             HT6 = 3,                          LO6 = 9, LR6 = 10,      tm6 = 12      ;
// *****************************************************************************************************************************************************************

void setup() {
  esp8266HTTPDinit(); //Keep at top!
  lcd.init();
  sensors.begin(); //For temp sensor
  lcd.backlight();
  lcd.print("Thermostat");
  Serial.begin(115200);

 

  // Array init loop
  int currentHH = 0;
  int currentMM = 0;
  millisPrior = readEEprom("longmillis");
  currentBlock = "A";
  currentTemp = 58;
}
void currentTime() {
  currentHH = 4;
  currentMM = 15;
}
void HCFanOn() {
  //A simple assurance FAN is on with system
  if ((digitalRead(AC6) == 1) || (digitalRead(HT6) == 1)) {
    digitalWrite(FN6, HIGH);
  }
}
void loop() {
  server.handleClient(); //Keep at top!
  tempTempSet(0);

  int menuAddrI;
  char *menuAddr;

  flasher(0, 0, 0, 0, 0, 0);
  subLoop++;
  if (subLoop > 120) {
    loop2();
    subLoop = 0;
  }
}

void loop2() {
  //debugSA();
  displayIt();
  currentBlockID();
  sensors.requestTemperatures(); // Send the command to get temperatures
  tempReading();
  systemUse();
  systemAction();
  lcd.setCursor(15, 0);
  int fanMode = readEEprom("fanMode");
  lcd.print(fanMode);
  // Serial.print(currentTemp); Serial.print("\t["); Serial.print(systemUse()); Serial.print(']'); Serial.println(modeName);
  //digitalWrite(13, !digitalRead(13));

}
void debugSA() {
  int arrTimeHH[8] = { 0 };
  int arrTimeMM[8] = { 0 };
  int arrTemp[8] = { 0 };
  EEPROM.get(210, arrTimeHH);
  EEPROM.get(230, arrTimeMM);
  EEPROM.get(250, arrTemp);
  for (int i = 0; i < 9; i++) {

    Serial.print(arrTimeHH[i]);
    Serial.print("\t\t"); //print tabs
    Serial.print(arrTimeMM[i]);
    Serial.print("\t\t"); //print tabs
    Serial.print(arrTemp[i]);
    Serial.println("."); //print tabs
    arrTimeHH[i] = i * 2;
    arrTimeMM[i] = i * 3;
    arrTemp[i] = 60 + i * 2;
  }
  Serial.print("---------------------------");
  EEPROM.put(210, arrTimeHH);
  EEPROM.put(230, arrTimeMM);
  EEPROM.put(250, arrTemp);
}
void lockScreen() {
  return;
  String lcdOut0;
  String lcdOut1;
  if (readEEprom("lock") == 0) return;
  lcdOut0 = "***T-stat Locked!**";
  locked = 1;
  menuStartMS = millis();
  seed = (random(0, 5));
  switch (seed) {
    case 0:
      lcdOut1 = "Press In";
      break;
    case 1:
      lcdOut1 = "Push up!";
      break;
    case 2:
      lcdOut1 = "Push Down";
      break;
    case 3:
      lcdOut1 = "Push Left";
      break;
    case 4:
      lcdOut1 = "Push Right!";
      break;
  }
  Serial.println(lcdOut0);
  Serial.println(lcdOut1);
  Serial.println("----------");

  lcd.clear();
  lcd.print(lcdOut0);
  lcd.setCursor(0, 1);
  lcd.print(lcdOut1);
}
float tempReading() {
  float tempRead;
  int totalTemp;
  float tempArray[31];
  int divisor;
  divisor = 0;
  //Take Temp reading
  tempRead = sensors.getTempCByIndex(0); //Temp for testing
  tempRead = DallasTemperature::toFahrenheit(tempRead);
  tempArray[tempReadI] = tempRead;
  tempReadI++;
  if (tempReadI > 30) tempReadI = 0;
  for (int i = 0; i < 31; i++) { //Add up temps
    if (tempArray[i] > 0) {
      divisor++;
      totalTemp = totalTemp + int(tempArray[i]);
    }
  }
  totalTemp = totalTemp / divisor;
  return constrain(totalTemp, 50, 90);
}

void timeSet(int dirc) {
  if (cursorPosition == 0) {
    readEEprom("HHOffset");
    HHOffset = HHOffset + 1 * dirc;
    writeEEprom("HHOffset", HHOffset);
    if (HHOffset > 23) {
      HHOffset = 0;  // rollover hours
    }
  }
  if (cursorPosition > 0) {
    readEEprom("MMOffset");
    MMOffset = MMOffset + 1 * dirc;
    writeEEprom("MMOffset", MMOffset);
    if (MMOffset > 59) {
      MMOffset = 0;  // Rollover minutes
    }
  }
}[CODE]

Code page 2

void ntpToggle() {
  int ntp = readEEprom("timeNTP"); //Get value
  ntp = !ntp; //toggle value
  writeEEprom("timeNTP", ntp); //Store value
}
void tfTimeout(int dirc) { //Actually the TEMPERATURE timeout change
  int data = readEEprom("tempTimeout");
  data = data + 15 * dirc;
  writeEEprom("tempTimeout", data);
}

void fanTimeout(int dirc) {
  int data = readEEprom("fanTimeout");
  data = data + 15 * dirc;
  writeEEprom("fanTimeout", data);
}

void scheduleTime(int dirc) {
  if (cursorPosition == 0) {
    scheduleHH =  scheduleArray(currentBlock, 'r', "timeHH", 0);
    scheduleHH = scheduleHH + 1 * dirc;
    scheduleArray(currentBlock, 'w', "timeHH", scheduleHH);
    if (scheduleHH < 0) {
      scheduleHH = 23;  // rollover hours
    }
  }
  if (cursorPosition > 0) {
    scheduleMM =  scheduleArray(currentBlock, 'r', "timeMM", 0);
    scheduleMM = - 15 * dirc;
    scheduleArray(currentBlock, 'w', "timeMM", scheduleMM);
    if (scheduleMM < 0) {
      scheduleMM = 59;  // Rollover minutes
    }
  }
}
void scheduleTempFx(int dirc) {
  scheduleTemp = scheduleArray(currentBlock, 'r', "temp", scheduleTemp);
  scheduleTemp = scheduleTemp + 1 * dirc;
  scheduleArray(currentBlock, 'w', "temp", scheduleTemp);
}
void fanHCConfirm() {
  writeEEprom("fanMode", 0);
}
void fanAllConfirm() {
  writeEEprom("fanMode", 1);
}
void fanPostMix(int dirc) {
  int data = readEEprom("fanPostMixTime");
  data = + 5 * dirc;
  writeEEprom("fanPostMixTime", data);
  handleRoot();
}

void tempTempSet(int dirc) {
  int data = 0;
  data = scheduleArray(currentBlock, 'r', "temperature", 0);
  if (tempSetting > 0) data = tempSetting;
  if (dirc == 1) data = data + 1;
  if (dirc == -1) data = data - 1;
  tempSetting = data;
  tempMS = millis();
  if (abs(dirc) == 1) {
    tempTemp = 1;
    handleRoot();
    tempMS = millis();
  }
}
void fanOnEvery(int dirc) {
  int data;
  writeEEprom("fanMode", 3);
  if (cursorPosition == 0) {
    data = readEEprom("fanFor");
    data + 15 * dirc;
    writeEEprom("fanFor", data);
  }
  if (cursorPosition > 0) {
    data = readEEprom("fanEvery");
    data = data + 15 * dirc;
    writeEEprom("fanEvery", data);
  }
  handleRoot();
}



void displayIt() {

  String lcdOut0 = "Currently " + String(currentTemp) + "F";
  String lcdOut1 = "Set at " + String(tempSetting);
  locked = readEEprom("lock");
  //Serial.println(lcdOut0);
  //Serial.println(lcdOut1);
  //Serial.println("----------");

  lcd.clear();
  lcd.print(lcdOut0);
  lcd.setCursor(0, 1);
  lcd.print(lcdOut1);
}
void systemAction() {
  fanLED();
  //System Modes

  switch (systemPrev) {
    case 0:
      modeName = "Standby";
      flasher(0, 0, 0, 0, 100, 0); //Internal off
      flasher(0, 1, 0, 0, 100, 0); //Red off
      flasher(0, 2, 0, 0, 100, 0); //Orange off
      flasher(0, 4, 0, 0, 100, 0); //Blue off
      digitalWrite(HT6, LOW);
      digitalWrite(AC6, LOW);
      digitalWrite(FN6, LOW);

      break;
    case 1: //FAN
      modeName = "Fan";
      //See below for flashers
      flasher(0, 0, 0, 0, 100, 0); //Internal off
      flasher(0, 1, 0, 0, 100, 0); //Red off
      flasher(0, 2, 0, 0, 100, 0); //Orange off
      flasher(0, 4, 0, 0, 100, 0); //Blue off
      digitalWrite(HT6, LOW);
      digitalWrite(AC6, LOW);
      digitalWrite(FN6, HIGH);

      break;
    case 2: // HEAT
      modeName = "Heat";
      flasher(0, 0, 0, 0, 100, 0); //Internal off
      flasher(0, 1, 0, 0, 100, 0); //Red off
      flasher(0, 2, 1000, 1, 1, 0); //Orange off
      flasher(0, 4, 0, 0, 100, 0); //Blue ON
      digitalWrite(HT6, HIGH);
      digitalWrite(AC6, LOW);
      digitalWrite(FN6, HIGH);

      break;
    case 3: //Cool / AC
      modeName = "Cooling";
      flasher(0, 0, 0, 0, 100, 0); //Internal off
      flasher(0, 1, 0, 0, 100, 0); //Red off
      flasher(0, 2, 0, 0, 100, 0); //Orange off
      flasher(0, 4, 1000, 1, 0, 0); //Blue ON
      digitalWrite(HT6, HIGH);
      digitalWrite(AC6, LOW);
      digitalWrite(FN6, HIGH);

      break;
  }
  //Fan Modes
}
void fanLED() {
  int fanMode = readEEprom("fanMode");

  if (fanMode == 0) flasher(0, 3, 0, 0, 900, 0); //on with hc - green off
  if (fanMode == 1) flasher(0, 3, 1000, 0, 0, 0); //All time - green FULL
  if (fanMode == 2) flasher(0, 3, 50, 0, 800, 0); //Post-mix - green flicker
  if (fanMode == 3) flasher(0, 3, 100, 0, 200, 0); //On every - green fast blink
}
int systemUse() {
  int systemFrom = systemPrev;
  systemPrev = systemUse2();
  if (systemPrev != systemFrom) {
    stateChange(systemFrom, systemPrev) ;
  }
  //Serial.print("SystemPrev:"); Serial.println(systemPrev);
  return systemPrev;
}
void stateChange(int from, int to) {
  int mins;
  msOn = millis();
  //Serial.print("State Change - From "); Serial.print(from); Serial.print(" to "); Serial.println(to);
  if (to == 1) fanOn = millis();
  if (to == 2) heatOn = millis();
  if (to == 3) coolOn = millis();
  if (from == 1) {
    mins = readEEprom("minsFan");
    mins = mins + ((millis() - fanOn) / 1000 * 60);
    writeEEprom("minsFan", mins);
  }
  if (from == 2) {
    mins = readEEprom("minsHeat");
    mins = mins + ((millis() - heatOn) / 1000 * 60);
    writeEEprom("minsHeat", mins);
  }
  if (from == 3) {
    mins = readEEprom("minsCool");
    mins = mins + ((millis() - coolOn) / 1000 * 60);
    writeEEprom("minsCool", mins);
  }
}

code page 3

int systemUse2() {
  //Determines which system to use.
  //0 is none, 1 fan, 2 heat, 3 cool
  char currentBlockI = 'A' + currentBlockID();
  //Serial.print(currentBlockI);
  //tempSetting = scheduleArray(currentBlockI, 'r', "temperature", 0);
  //Serial.print('['); Serial.print(tempSetting); Serial.print(']');
  //It SHOULD be tempSetting, but it is currentTemp
  int fanMode = readEEprom("fanMode"); // 0 = default on w/ HC, 1 = On all time, 2 = post-mix, 3 = on every...
  //Serial.print(fanMode);

  int tempDiff = (currentTemp - tempSetting);
  int  hysteresis = readEEprom("hysteresis");
  //Proper hysteresis. Turn OFF (0/1) == setTemp. Turn ON when abs(current - set) >= hysteresis
  //Serial.println(hysteresis);
  //Serial.print("TempDiff: "); Serial.println(tempDiff);
  if (systemPrev == 0) {
    //Turning on!
    if (abs(tempDiff) > hysteresis) {
      systemOnMS = millis();
      if (tempDiff > 0) return 3; //COOL ON
      if (tempDiff < 0) return 2; //HEAT ON
    }
  }
  if (systemPrev > 0) {
    //running... otherwise turning off...
    if (tempDiff > 0) {
      return 3; //COOL
    }
    if (tempDiff < 0) {
      return 2;  //HEAT
    }
  }
  if (fanMode == 0) {
    return 0;
  }
  if (fanMode == 1) {
    return 1;
  }
  if (fanMode == 2) {
    //find out how long system has been off
    int systemOffMins = ((millis() - systemOnMS) / 60000);
    int fanPostMixTime = readEEprom("fanPostMixTime");
    if (systemOffMins <= fanPostMixTime) {
      return 1;
    }
    else {
      return 0;
    }
  }
  //
}
int currentBlockID() {
  //returns current block where 0 = A...
  int HH, MM, n;
  char block;
  char* Block;

  for (n = 0; n < 9; n++) {
    block = 'A' + n;
    Block = &block;
    HH = scheduleArray(Block, 'r', "timeHH", 0);
    MM = scheduleArray(Block, 'r', "timeMM", 0);
    if ((currentHH >= HH) && (currentMM >= MM)) {
      break;
    }
  }
  char *currentBlock = &block;

  return n;
}


//void displayIt() { } //dummy entry



int scheduleArray(char *Block, char rw, char* item, int data) {
  int block;
  int out;
  int arrTimeHH[8], arrTimeMM[8], arrTemp[8];

  out = 0;
  block = atoi(Block);
  //strcpy(block,Block);


  //Serial.print('['); Serial.print(item); Serial.print(']');
  if (rw == 'r') { //Read data
    EEPROM.get(210, arrTimeHH);
    EEPROM.get(230, arrTimeMM);
    EEPROM.get(250, arrTemp);
    if (strcmp(item, "timeHH") == 0) {
      out = arrTimeHH[block];
    }
    if (strcmp(item, "timeMM") == 0) {
      out = arrTimeMM[block];
    }
    if (strcmp(item, "temperature") == 0) { //Do NOT use "temp" - for some reason doesn't work.
      out = arrTemp[block];
    }
  }
  if (rw == 'w') { //Write data
    if (strcmp(item, "timeHH") == 0) {
      arrTimeHH[block] = data;
      EEPROM.put(210, arrTimeHH);
    }
    if (strcmp(item, "timeMM") == 0) {
      arrTimeMM[block] = data;
      EEPROM.put(230, arrTimeMM);
    }
    if (strcmp(item, "temperature") == 0) {
      arrTemp[block] = data;
      EEPROM.put(250, arrTemp);
    }
  }
  return out;
}
void block(int dirc) {
  if (dirc == -1) {

    if (strcmp(currentBlock, "") == 0) {
      currentBlock = "H";
      return;
    }
    currentBlock = currentBlock + dirc;
    if (strcmp(currentBlock, "A") == 0) {
      currentBlock = "H";
      return;
    }
  }

  if (dirc == 1) {
    if (strcmp(currentBlock, "") == 0) {
      currentBlock = "A";
      return;
    }
    currentBlock = currentBlock + dirc;
    if (strcmp(currentBlock, "H") == 0) {
      currentBlock = "A";
      return;
    }
  }

}
void flasher(int mode, int color, int intv1MS, int intv1Lev, int intv2MS, int intv2Lev) {
  int colorLED, colorL, state;
  //Serial.print(readEEprom("fanMode"));
  // flasher(0, 2, 200, 20, 500, 200)
  //first check if new flash request
  if ((intv1MS + intv2MS) > 0) { //new flash -- ** MUST NOT be called faster than interval total! **
    //Serial.println(intv1MS + intv2MS) ;
    //store vars into array
    flasherA[color][0] = mode;
    flasherA[color][1] = intv1MS;
    flasherA[color][2] = intv1Lev;
    flasherA[color][3] = intv2MS;
    flasherA[color][4] = intv2Lev;
    flasherL[color] = millis();
  }
  //cycle colors
  for (colorL = 0; colorL < 5; colorL++) {
    switch (colorL) {
      case 0:
        colorLED = LED;
        state = digitalRead(LED);
        break;
      case 1:
        colorLED = LR6;
        state = digitalRead(LR6);
        break;
      case 2:
        colorLED = LO6;
        state = digitalRead(LO6);
        break;
      case 3:
        colorLED = LG6;
        state = digitalRead(LG6);
        break;
      case 4:
        colorLED = LB6;
        state = digitalRead(LB6);
        break;
    }
    if (state == LOW) {
      if ((millis() - flasherL[colorL]) > flasherA[colorL][3]) {
        flasherL[colorL] = millis();
        flasherA[colorL][6] = HIGH; //flasherA[colorL][4];
        digitalWrite(colorLED, flasherA[colorL][6]);
      }
    }
    if (state == HIGH) {
      if (flasherA[colorL][3] == 0) {
        return;  //Keep on, ON!
      }
      if ((millis() - flasherL[colorL]) > flasherA[colorL][1]) {
        flasherL[colorL] = millis();
        flasherA[colorL][6] = LOW; //flasherA[colorL][2];
        digitalWrite(colorLED, flasherA[colorL][6]);
      }
    }
    if (flasherA[colorL][1] == 0) {
      digitalWrite(colorLED, LOW);
    }
  }
}

int readEEprom(String itemName) {
  unsigned long eAddr, outVar;
  eAddr = eAddrRef(itemName);
  if (eAddr == -1)  {
    outVar = -1;
    return 0;
  }
  EEPROM.get(eAddr, outVar);
  return outVar;
}
void writeEEprom(String itemName, unsigned long value) {
  int eAddr, valueInt;
  valueInt = int(value);
  if (itemName.substring(0, 4) == "long") {
    EEPROM.put(eAddr, value);
  }
  else {
    EEPROM.put(eAddr, valueInt);
  }
  eAddr = eAddrRef(itemName);
  EEPROM.put(eAddr, value);
}
int eAddrRef(String itemName) { //Looks up address from name. Provides a address and name cross-reference
  int eAddr;
  eAddr = -1; //If falls through without match, address -1
  if (itemName == "tempTimeout") { // Temperature change reverts in n minutes.
    eAddr = 0;
  }
  if (itemName == "temperature") { // Current read temp.
    eAddr = 2;
  }
  if (itemName == "temperatureSet") { //Current set temp.
    eAddr = 3;
  }
  if (itemName == "timeBlocks") { // Number of time slots to display & use
    eAddr = 4;
  }
  if (itemName == "tempX") { // temp setting at midnight. Rest stored in array.
    eAddr = 38;
  }
  if (itemName == "lock") { // To use lock, 0 for off.
    eAddr = 40;
  }
  if (itemName == "unlockTime") { //Time to stay unlocked
    eAddr = 42;
  }
  if (itemName == "timeNTP") { // Use NTP Server?
    eAddr = 44;
  }
  if (itemName == "fanTimeout") {
    eAddr = 46;
  }
  if (itemName == "hysteresis") {
    eAddr = 48;
  }
  if (itemName == "fanMode") { // 0 = default on w/ HC, 1 = On all time, 2 = post-mix, 3 = on every...
    eAddr = 50;
  }
  if (itemName == "fanPostMixTime") { // n of mins to post-mix (run fan after HC cycle)
    eAddr = 52;
  }
  if (itemName == "longmillis") {
    eAddr = 54;
  }
  if (itemName == "MMOffset") {
    eAddr = 60;
  }
  if (itemName == "HHOffset") {
    eAddr = 62;
  }
  if (itemName == "fanFor") {
    eAddr = 64;
  }
  if (itemName == "fanEvery") {
    eAddr = 66;
  }
  if (itemName == "tempTimeout") {
    eAddr = 68;
  }
  if (itemName == "minsFan") {
    eAddr = 70;
  }
  if (itemName == "minsHeat") {
    eAddr = 72;
  }
  if (itemName == "minsCool") {
    eAddr = 74;
  }

  return eAddr;
  if (eAddr == -1) {
    Serial.println("No eAddr tag found!");
  }
}

Page 4. Here is the most relevent section of code.

void esp8266HTTPDinit() {
  WiFi.mode(WIFI_STA);
  IPAddress ip(192, 168, 1, 135);
  IPAddress gw(192, 168, 1, 254);
  IPAddress dns(192, 168, 1, 254);
  IPAddress sn(255, 255, 255, 0);
  WiFi.config(ip, gw, sn, dns);
  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("esp8266")) {
    Serial.println("MDNS responder started");
  }

  server.on("/", handleRoot);

  server.on("/inline", []() {
    server.send(200, "text/plain", "this works as well");
  });
  server.on("/tempUp", []() {
    wwwTemp(1);
  });
  server.on("/tempDown", []() {
    wwwTemp(-1);
  });

  server.onNotFound(handleNotFound);

  server.begin();
  Serial.println("HTTP server started");
}
void wwwTemp(int dirc) {
  tempTempSet(dirc);
  handleRoot();
}
void fanOnEveryFor(int dirc) {
  cursorPosition = 0;
  fanOnEvery(dirc);
  handleRoot();
}
void fanOnEveryE(int dirc) {
  cursorPosition = 1;
  fanOnEvery(dirc);
  handleRoot();

}
void fanModeSet(int fanModeS) {
  fanMode = fanModeS;
  handleRoot();
}
void handleRoot() { //Content of page is here.
  int fanMode = readEEprom("fanMode");
  int fanPostMixTime = readEEprom("fanPostMixTime");
  int fanFor = readEEprom("fanFor");
  int fanEvery = readEEprom("fanEvery");
  int hoursFan = readEEprom("minsFan");
  int hoursHeat = readEEprom("minsHeat");
  int hoursCool = readEEprom("minsCool");
  char hoursFanA[6];
  char hoursHeatA[6];
  char hoursCoolA[6];
  hoursFan = (hoursFan / 60);
  hoursHeat = (hoursHeat / 60);
  hoursCool = (hoursCool / 60);
  itoa(hoursFan, hoursFanA, 10);
  itoa(hoursHeat, hoursHeatA, 10);
  itoa(hoursCool, hoursCoolA, 10);
  char html0[800] = { 0 }, html0b[100] = { 0 };
  char tempSettingA[4];
  char currentTempA[4];
  unsigned long minsOn = ((millis() - msOn) / 60000);
  //server.send(200,"text/plain","Testing");
  //return;
  Serial.print("Mins on:"); Serial.print(minsOn);
  char minsOnA[4];
  itoa(minsOn, minsOnA, 10);
  itoa(tempSetting, tempSettingA, 10);
  itoa(currentTemp, currentTempA, 10);
  strcpy(html0, "<html><head><title>Thermostat v0.1</title> <style> .buttonBlue { background-color: #1010B0; color: white; font-size: 16px; } .buttonRed { background-color: #D01010; color: white; font-size: 16px; } </style></head>");
  strcat(html0, 
  strcat(html0,"<body><hr> System: ");
  modeName.toCharArray(html0b, 8);
  strcat(html0,html0b);
  strcat(html0, " on for ");
  strcat(html0, minsOnA);
  strcat(html0, "mins. <hr>);


  
  strcat(html0, tempSettingA);
  strcat(html0, "</font><font size=3> Currently:");
  strcat(html0, currentTempA);
  if (fanMode == 0) strcat(html0, "
 </font><input type='submit' formAction='/036' value='Down'>
<hr><font color = black><a href=0290000><b> * Fan on With H/C * </b></a>
 <a href=0290010> Fan on All Time </a>
 <a href=0290020> Fan Post-mix </a>
 <a href=0290021> - </a>");
  if (fanMode == 1) strcat(html0, "
 </font><input type='submit' formAction='/036' value='Down'>
<hr><font color = black><a href=0290000> Fan on With H/C </a>
 <a href=0290010><b> * Fan on All Time * </b> </a>
 <a href=0290020> Fan Post-mix </a>
 <a href=0290021> - </a>");
  if (fanMode == 2) strcat(html0, "
 </font><input type='submit' formAction='/036' value='Down'>
<hr><font color = black><a href=0290000> Fan on With H/C </a>
 <a href=0290010> Fan on All Time </a>
 <a href=0290020><b> * Fan Post-mix * </b></a>
 <a href=0290021> - </a>");
  if (fanMode == 3) strcat(html0, "
 </font><input type='submit' formAction='/036' value='Down'>
<hr><font color = black><a href=0290000> Fan on With H/C </a>
 <a href=0290010> Fan on All Time </a>
 <a href=0290020>Fan Post-mix</a>
 <a href=0290021> - </a>");
  char fanPostMixTimeA[4];
  itoa(fanPostMixTime, fanPostMixTimeA, 10);
  strcat(html0, fanPostMixTimeA);
  if (fanMode < 3)   strcat(html0, "Mins <a href=0290022> + </a>
 <a href=0290030> Fan on FOR... Every...  </a>
 <a href=0290031>  - </a>");
  if (fanMode == 3)  strcat(html0, "Mins <a href=0290022> + </a>
 <a href=0290030><b> * Fan on FOR... Every... * </b> </a>
 <a href=0290031>  - </a>
");
  char fanForA[4];
  char fanEveryA[4];
  itoa(fanFor, fanForA, 10);
  strcat(html0, fanForA);
  strcat(html0, "Mins <a href=0290032> + </a> <a href=0290033> &nbsp &nbsp &nbsp &nbsp - </a>");

  itoa(fanEvery, fanEveryA, 10);
  strcat(html0, fanEveryA);
  strcat(html0, "Mins <a href=0290034> + </a>");
  strcat(html0, "<hr>Run times in hours
<table><tr><th>Fan</th><th>Heat</th><th>Cool</th><tr>");
  strcat(html0, "<td>");
  strcat(html0, hoursFanA);
  strcat(html0, "</td><td>");
  strcat(html0, hoursHeatA);
  strcat(html0, "</td><td>");
  strcat(html0, hoursCoolA);
  strcat(html0, "</td></tr></table>");
  
  server.send(200, "text/html",html0);
}
void handleSchedule() {
  char html0[550] = { 0 }, html0b[550] = { 0 }, html0c[550] = { 0 }, html1[200] = { 0 }, html2[200] = { 0 }, html3[300] = { 0 }, html4[100] = { 0 };
  char* scheduleHHA = { 0 };
  char* scheduleMMA = { 0 };
  char* scheduleTempA = { 0 };
  int scheduleHHi, scheduleMMi, scheduleTempi;
  char buff[10] = { 0 };

  currentBlock = "A";
  // char *pCurrentBlock = &currentBlock;
  strcpy(html0, "<!DOCTYPE html><html><head><title>Thermostat Schedule</title></head><body><hr>");
  strcat(html0, "<hr><font color=violet size=4> Schedule </font><table><tr><th> Time </th > <th> Temp. </th> <tr><td><a href=AHHUp> + </a>");



  for (int i = 0; i < 8; i++) {


    itoa(scheduleArray(currentBlock, 'r', "timeHH", 0), scheduleHHA, 10);
    itoa(scheduleArray(currentBlock, 'r', "timeMM", 0), scheduleMMA, 10);
    itoa(scheduleArray(currentBlock, 'r', "temperature", 0), scheduleTempA, 10);


    strcpy(html0, "<a href=");
    strcat(html0, currentBlock);
    strcat(html0, "HHDown> - </a>");

    strcat(html0, scheduleHHA);

    strcat(html0, "<a href=");
    strcat(html0, currentBlock);
    strcat(html0, "HHUp> + </a>");

    strcat(html0, ": <a href=");
    strcat(html0, currentBlock);
    strcat(html0, "MMDown> - </a>");

    strcat(html0, scheduleMMA);

    strcat(html0, "<a href=");
    strcat(html0, currentBlock);
    strcat(html0, "MMUp> + </a>");
    strcat(html0, " </td> <td>");

    strcat(html0, "<a href=");
    strcat(html0, currentBlock);
    strcat(html0, "TempDown> - </a>");

    strcat(html0, scheduleTempA);

    strcat(html0, "<a href=");
    strcat(html0, currentBlock);
    strcat(html0, "TempUp> + </a>");
    strcat(html0, "</td></tr><tr><td>");

   currentBlock++;
  }
  strcat(html0, " </table> </body> </html> ");


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

}
void handleNotFound() {
  digitalWrite(13, 1);
  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);
  digitalWrite(13, 0);
}

Since you have a very specific, focused issue, why not post an MCVE that just demonstrates the issue at hand? Cut out the rest of the code which is just extraneous noise.

If you want to put “this is in quotes” into a string, so you can print
Some text with quotes: [“this is in quotes”]
you’d do something like this:

char *text = “Some text with quotes: [“this is in quotes”]”;

So, everywhere your html contains a ", change it to ".

Thanks! - It’s my next project. Son is messing with the thermostat. So I figured out the most complicated solution possible, heh.