capacitive soil sensor update on WebServer (school project).

My daughter has a school project to make any useful invention. She chose to make a device named the Plant-O-Meter, and it will display the temperature,humidity,and soil moisture level of a plant on any device with an internet browser. She is using a DHT11 for temp and humidity and a capacitive soil sensor to read soil moisture, and while I know this is a Arduino forum, and we are using an esp32 due to size and built in wifi, we are using the Arduino IDE, this seems to be a programing problem not a hardware problem.

the sensor seems to be working without a problem if we use

  const int soilSensor = 15;
  int soilVal = 0;

void setup() {
  
  Serial.begin(115200);
}

void loop() 
{
  soilVal = analogRead(soilSensor);
  int soil = map(soilVal, 3350, 1500, 0, 100);
  soil = constrain(soil, 0, 100);

  Serial.print(soilVal);
  Serial.print(">>>>>");
  Serial.println(soil);
  delay(2000);
  

}

But when we add it to the DHT11 code (works without a problem) it is not reading the sensor.

#include <WiFi.h>
#include <WebServer.h>
#include <WiFiClient.h>
#include "DHT.h"

#define DHTPIN 4
#define DHTTYPE DHT11

const char* ssid = "Plant-O-Meter";
const char* password = "SHARKTANK2019";
const int soilSensor = 15;
int soilVal = 0;

IPAddress local_ip(192,168,1,1);
IPAddress gateway(192,168,1,1);
IPAddress subnet(255,255,255,0);

WebServer server(80);

DHT dht(DHTPIN, DHTTYPE);

void setup() 
{
dht.begin();
Serial.begin(115200);
delay(100);
WiFi.mode(WIFI_AP);

server.begin();

WiFi.softAP(ssid,password);
WiFi.softAPConfig(local_ip, gateway, subnet);
server.on("/", handle_OnConnect); 
delay(100);

}

void loop() 

{
server.handleClient();

}

void handle_OnConnect()
{
float temp = dht.readTemperature(true);
float humid = dht.readHumidity();
soilVal = analogRead(soilSensor);
  int soil = map(soilVal, 3350, 1500, 0, 100);
  //soil = constrain(soil, 0, 100);

server.send(200, "text/html", SendHTML(temp,humid, soil));
}

void handle_NotFound(){server.send(404, "text/plain", "Not Found");}

String SendHTML(float temp, float humid, int soil)
{
 String ptr = "<!DOCTYPE html> <html>\n";
  ptr +="<head><meta name=\"viewport\" content=\"width=device-width, initial-scale=1.0, user-scalable=no\">\n";
  ptr +="<title>Plant-O-Meter </title>\n";
  ptr +="<style>html { font-family: Helvetica; display: inline-block; margin: 0px auto; text-align: center;}\n";
  ptr +="body{margin-top: 50px;} h1 {color: #444444;margin: 50px auto 30px;}\n";
  ptr +="p {font-size: 24px;color: #444444;margin-bottom: 10px;}\n";
  ptr +="</style>\n";
ptr +="<script>\n";
ptr +="setInterval(loadDoc,250);\n";
ptr +="function loadDoc() {\n";
ptr +="var xhttp = new XMLHttpRequest();\n";
ptr +="xhttp.onreadystatechange = function() {\n";
ptr +="if (this.readyState == 4 && this.status == 200) {\n";
ptr +="document.body.innerHTML =this.responseText}\n";
ptr +="};\n";
ptr +="xhttp.open(\"GET\", \"/\", true);\n";
ptr +="xhttp.send();\n";
ptr +="}\n";
ptr +="</script>\n";
  ptr +="</head>\n";
  ptr +="<body>\n";
  ptr +="<div id=\"webpage\">\n";
  ptr +="<h1>Plant-O-Meter</h1>\n";
  ptr +="<p>Temperature: ";
  ptr +=temp;
  ptr +="&deg;F</p>";
  ptr +="<p>Humidity: ";
  ptr +=humid;
  ptr +="%</p>";
  ptr +="<p>Soil Moisture: ";
  ptr +=soil;
  ptr +="%</p>";
  ptr +="</div>\n";
  ptr +="</body>\n";
  ptr +="</html>\n";
  return ptr;
}

The DHT11 updates and displays properly, but the soil sensor will not.

I am sorry if this is sloppy, I have no background in programing, and she is only 8 years old. This project is due in 3 days, any help at all we would be very grateful. I would like to make as few changes to the code as possible, she will need to present this in a few days, she did all the programing so far, and understands all of it so far, but don't want to over load her with a ton of new stuff in such a short time frame.

Choose an ADC pin that hangs off ADC1, not ADC2. ADC2 cannot be used if you are using WiFi.

BTW: Impressive 8 year old that can grok a project like this. Well done!

OMG, I can not believe I did that. Thank you so much. Funny, at the start of the project, when she picked GPIO 15, I told her then she was going to have problems later with that, but didn't tell her why because I wanter her to have to troubleshoot her own code.....and I somehow forgot it :-(. thank you again, I can not believe I didn't think of that.