hi guys so i was trying to compile my sketch and i keep getting this error
exit status 1
‘handleTEMP’ was not declared in this scope.
and i check but i dont see anything wrong why is this happening?
this is my code.
#ifdef ESP8266
#include <ESP8266WiFi.h>
#include <ESP8266WebServer.h>
ESP8266WebServer server(80);
#else
#include <WiFi.h>
#include <WebServer.h>
#endif
#include "DHT.h"
#define DHTPIN 13 //PIN D7
#define DHTTYPE DHT22
#include <WiFiClient.h>
DHT dht(DHTPIN, DHTTYPE);
//Define name of the Wifi & password for creating an access point
const char* ssid = "neneboots";
const char* password = "87654321";
//!!!Your password MUST be a minimum of 8 characters...otherwise neither password nor ssid will be accepted -> default or old ssid&pwd will show up!!!
//Variables
String stemp,shumi,sinte,a;
float ftemp,fhumi,finte,t,h,f;
//WebPage-----------------------------------------------------------
char webpage[] = R"=(
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="generator" content="CoffeeCup HTML Editor (www.coffeecup.com)">
<meta name="dcterms.created" content="Mon, 06 Jan 2020 05:20:17 GMT">
<meta name="description" content="">
<meta name="keywords" content="">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Blue Light</title>
<style type="text/css">
<!--
body {
color:#000000;
background-color: #0000FF;
background-image:url('Background Image');
background-repeat:no-repeat;
border:3px;
border-style:solid;
border-color:#000000;
padding: 1em;
font-family:calibri;
}
a { color:#0000FF; }
a:visited { color:#800080; }
a:hover { color:#008000; }
a:active { color:#FF0000; }
-->
.content {
text-align:leftr;
font-size: large;
max-width: 500px;
min-height: 30px;
margin: auto;
}
</style>
</head>
<body class="content">
<h2 class="content">Blue Light Incubator</h2>
<input type="text" id="alrt"><span id="ALERvalue"></span></input>
<form method="post" action="/postForm">
<div class="content">
<label for=temperature> Temperature </label></div>
<div class="content"><input type="number" name="myTemp" id="temperature" placeholder="°C" min="0" max="255" required></input>
</div>
<h4>Temperature reading: <span id="TEMPvalue">0</span>°</h4>
<div class="content">
<label for=humidity> Humidity </label></div>
<div class="content"><input type="number" name="myHumi" id="humidity" placeholder="Units" min="0" max="255" required></input>
</div>
<h4>Humidity reading: <span id="HUMIvalue">0</span>%</h4>
<div class="content">
<label for=intensity> Light Intensity</label></div>
<div class="content"><input type="number" name="myInte" id="intensity" placeholder="Lux" min="0" max="1023" required></input>
</div>
<h4>Light Intensity: <span id="LIGHvalue">0</span>lux</h4>
<div class="content">
<input type="submit" value="Apply Settings"></input>
</div>
</form>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<script>
setInterval(function() {getSensorData();}, 500); // Call the update function every set interval e.g. 1000mS or 1-sec
function getSensorData() {
var xhttp = new XMLHttpRequest();
xhttp.onreadystatechange = function() {
if (this.readyState == 4 && this.status == 200) {
document.getElementById("TEMPvalue").innerHTML = this.responseText;
}
};
xhttp.open("GET", "TEMPread", true);
xhttp.send();
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
var xhttp = new XMLHttpRequest();
xhttp.onreadystatechange = function() {
if (this.readyState == 4 && this.status == 200) {
document.getElementById("HUMIvalue").innerHTML = this.responseText;
}
};
xhttp.open("GET", "HUMIread", true);
xhttp.send();
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
var xhttp = new XMLHttpRequest();
xhttp.onreadystatechange = function() {
if (this.readyState == 4 && this.status == 200) {
document.getElementById("LIGHvalue").innerHTML = this.responseText;}
};
xhttp.open("GET", "LIGHread", true);
xhttp.send();
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
var xhttp = new XMLHttpRequest();
xhttp.onreadystatechange = function() {
if (this.readyState == 4 && this.status == 200) {
document.getElementById("ALERvalue").innerHTML = this.responseText;
document.body.style.background = this.responseText == '0' ? 'red' : 'blue'
}
};
xhttp.open("GET", "ALERread", true);
xhttp.send();
}
</script>
</body>
</html>
)=";
//Setup-----------------------------------------------------------------
void setup() {
pinMode(5,OUTPUT);
Serial.begin(115200);
Serial.print("CONNECTING TO");
Serial.println(ssid);
WiFi.begin(ssid, password);
while (WiFi.status() != WL_CONNECTED) {
delay(400);
Serial.print("-");
}
Serial.println("");
Serial.println("WIFI CONNECTED!");
server.begin();
Serial.println("MINI SERVER STARTS AT : ");
Serial.println(WiFi.localIP());
//Server________________________________
server.begin();
server.on("/TEMPread", handleTEMP); // To update Temperature called by the function getSensorData
server.on("/HUMIread", handleHUMI); // To update Humidity called by the function getSensorData
server.on("/LIGHread", handleLIGH); // To update Pressure called by the function getSensorData
server.on("/ALERread", handleALER);
server.on("/postForm", handlePostForm);
//DHT------------------------------
dht.begin();
}
//Loop------------------------------------------------------------------------------------
void loop() {
Serial.println(finte);
analogWrite(5,finte);
t = dht.readTemperature();
h = dht.readHumidity();
f = 0.00;
a = random(0,1);
server.handleClient();
// Read temperature as Celsius (the default)
if (isnan(h) || isnan(t) || isnan(f)) {
Serial.println(F("Failed to read from DHT sensor!"));
return;
}
delay(500);
// Reading temperature or humidity takes about 250 milliseconds!
// Sensor readings may also be up to 2 seconds 'old' (its a very slow sensor)
//Arduino Mega Serial ------------------------------------------------------------------
if(t <= ftemp){ // 1111111111111111111111111111
Serial.println("1");
Serial.println("\n");
}
else{
Serial.println("2"); //222222222222222222222222
Serial.println("\n");
}
if(h <= fhumi){ //33333333333333333333333
Serial.println("3");
Serial.println("\n");
}
else{
Serial.println("4"); //4444444444444444444444
Serial.println("\n");
}
}
//
void serialTx() {
}
//Handles--------------------------------------------------------
void handlePostForm()
{
shumi=server.arg("myHumi");
stemp=server.arg("myTemp");
sinte=server.arg("myInte");
fhumi= shumi.toFloat();
ftemp= stemp.toFloat();
finte= sinte.toFloat();
Serial.println("Settings Applied.");
Serial.println(ftemp);
Serial.println(fhumi);
Serial.println(finte);
server.send(200, "text/html", webpage);
}
//----------------------------------------------------------------------------------
void handleTEMP() { // This function is called by the script to update the sensor value, in this example random data!
// temp = String(bme.readTemperature(),2);
// server.send(200, "text/plain", temp));
server.send(200, "text/plain", String(t)); //Send sensor reading when there's a client ajax request
}
void handleHUMI() { // This function is called by the script to update the sensor value, in this example random data!
server.send(200, "text/plain", String(h)); //Send sensor reading when there's a client ajax request
}
void handleLIGH() { // This function is called by the script to update the sensor value, in this example random data!
server.send(200, "text/plain", String(f)); //Send sensor reading when there's a client ajax request
}
void handleALER() { // This function is called by the script to update the sensor value, in this example random data!
server.send(200, "text/plain", String(a)); //Send sensor reading when there's a client ajax request
}