Code error when changing place why ?

please see the code below:
I get error:

C:\Users\Roee\Documents\Arduino\AdvancedWebServer_v5_ok\AdvancedWebServer_v5_ok.ino: In function 'void roee_clk_run_always()':
C:\Users\Roee\Documents\Arduino\AdvancedWebServer_v5_ok\AdvancedWebServer_v5_ok.ino:194:15: error: invalid operands of types 'int' and '' to binary 'operator<'
194 | if (min_old < min) ){
| ~~~~^
C:\Users\Roee\Documents\Arduino\AdvancedWebServer_v5_ok\AdvancedWebServer_v5_ok.ino:194:22: error: expected primary-expression before ')' token
194 | if (min_old < min) ){
| ^

exit status 1

Compilation error: invalid operands of types 'int' and '' to binary 'operator<'

while if I put the lines:

if (min_old < min) ){
Serial.print("one min ");
Serial.print(min_count);
Serial.print(" Temp:");
Serial.println (temp_int);
min_old= int(min);
min_count++;
}

inside
void handleRoot

this is working...
The reason I want to change the place is since I want to have minutes count even if the HTTP page is not connected to server

Here is the full code with error:

/*
   Copyright (c) 2015, Majenko Technologies
   All rights reserved.

   Redistribution and use in source and binary forms, with or without modification,
   are permitted provided that the following conditions are met:

 * * Redistributions of source code must retain the above copyright notice, this
     list of conditions and the following disclaimer.

 * * Redistributions in binary form must reproduce the above copyright notice, this
     list of conditions and the following disclaimer in the documentation and/or
     other materials provided with the distribution.

 * * Neither the name of Majenko Technologies nor the names of its
     contributors may be used to endorse or promote products derived from
     this software without specific prior written permission.

   THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
   ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
   WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
   DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
   ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
   (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
   LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
   ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
   (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
   SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/

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

#ifndef STASSID
#define STASSID "Roee2"
#define STAPSK "0502147870"
#define Temp_array_size 10
#endif

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

const int analogInPin = A0;  // ESP8266 Analog Pin ADC0 = A0

//Roee for Temp

int Vo;
float R1 = 1586.1;
float logR2, R2, T, Tc, Tf;
float c1 = 1.630740587e-03, c2 = 1.387891336e-04, c3 = 17.90745831e-07,deg1=0;
int x=10,y2=10,temp_int,temp_int_old,sec_old,sec=0,min_old=0,min_count=1;
int Temp_array[Temp_array_size],Temp_array_place;
//

ESP8266WebServer server(80);

const int led = 13;

int sensorValue = 0;  // value read from the port A0
 
  

void handleRoot() {
  digitalWrite(led, 1);
  sec_old=sec;
  
  sec = millis() / 1000;
  int min = sec / 60;
  int hr = min / 60;

 // Serial.println("handler");
  if (sec !=  sec_old) Serial.println("one sec");
  StreamString temp;
  temp.reserve(500);  // Preallocate a large chunk to avoid memory fragmentation
  temp.printf("\
<html>\
  <head>\
    <meta http-equiv='refresh' content='5'/>\
    <title>ESP8266 Demo</title>\
    <style>\
      body { background-color: #cccccc; font-family: Arial;font-size: 30; Helvetica, Sans-Serif; Color: #000088; }\
    </style>\
  </head>\
  <body>\
    <h2>Temperature Meter By Roee B</h2>\
    <p>Uptime: %02d:%02d:%02d</p>\
     <h1> Temperature: %2.1f C</h1>\
    <img src=\"/test.svg\" />\
  </body>\
</html>",
              hr, min % 60, sec % 60, Tc);
  server.send(200, "text/html", temp.c_str());
  digitalWrite(led, 0);
  sensorValue = analogRead(analogInPin);
  
}

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

void drawGraph() {
  String out;
  out.reserve(2600);
  char temp[70];
  Roee_temp_calc();
  out += "<svg xmlns=\"http://www.w3.org/2000/svg\" version=\"1.1\" width=\"400\" height=\"150\">\n";
  out += "<rect width=\"400\" height=\"150\" fill=\"rgb(250, 230, 210)\" stroke-width=\"1\" stroke=\"rgb(0, 0, 0)\" />\n";
  out += "<g stroke=\"black\">\n";
 // int y = rand() % 130;
  while (x<390)
  {
   temp_int =  int(round(Tc));
   int y=100;
   while (x<390){
    sprintf(temp, "<line x1=\"%d\" y1=\"%d\" x2=\"%d\" y2=\"%d\" stroke-width=\"1\" />\n", x, 100+temp_int_old, x + 10, 100 +temp_int);
  //  out += temp;
   x=x+10;
  }
  out += "</g>\n</svg>\n";

  server.send(200, "image/svg+xml", out);
  }
}

void setup(void) {
  pinMode(led, OUTPUT);
  digitalWrite(led, 0);
  Serial.begin(115200);
  WiFi.mode(WIFI_STA);
  WiFi.begin(ssid, password);
  Serial.println("");

  for (int j=0;j<Temp_array_size; j++)
  Temp_array[j]=0;

  // 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("/test.svg", drawGraph);
  server.on("/inline", []() {
    server.send(200, "text/plain", "this works as well");
  });
  server.onNotFound(handleNotFound);
  server.begin();
  Serial.println("HTTP server started");
}

void Roee_temp_calc()
{
  temp_int_old =  int(round(Tc));
  Vo = analogRead(analogInPin);
  R2 = R1 * (1023.0 / (float)Vo - 1.0);
  logR2 = log(R2);
  T = (1.0 / (c1 + c2*logR2 + c3*logR2*logR2*logR2));
  Tc = T - 273.15;
  Tf = (Tc * 9.0)/ 5.0 + 32.0; 
  deg1=Tc;
//  Serial.print("temp calc");

}

void roee_clk_run_always()
{
   //min = sec / 60;
  if (min_old < min) ){
     Serial.print("one min ");
     Serial.print(min_count);
     Serial.print("  Temp:");
     Serial.println (temp_int);
    min_old= int(min);
    min_count++;
  }
  }
void Push_array_temp( int new_temperature) // push new value to array
{
     for (int j=1; j<Temp_array_size; j++)
     Temp_array[j+1] = Temp_array[j];
     Temp_array[0] = new_temperature;


}




void loop(void) {
  server.handleClient();
  roee_clk_run_always();
  MDNS.update();
 
}

type or paste code here

type or paste code here

Your min_old variable is global so always visible but you have not declared your min variable. You declare it inside handleRoot() so it is only visible within that function.

 if (min_old < min) ){

One opening brace and two closing braces ?

NOP
I have tried already before posting this to declare int min as global
This did not work, and I had many more errors.
Please try to compile to see that your suggestion is working, before sending it
Thanks,
Roee.

C:\Users\Roee\Documents\Arduino\AdvancedWebServer_v5_ok\AdvancedWebServer_v5_ok.ino:55:50: error: 'int min' conflicts with a previous declaration
55 | int Temp_array[Temp_array_size],Temp_array_place,min;
| ^~~
In file included from c:\users\roee\appdata\local\arduino15\packages\esp8266\tools\xtensa-lx106-elf-gcc\3.1.0-gcc10.3-e5f9fec\xtensa-lx106-elf\include\c++\10.3.0\bits\specfun.h:45,
from c:\users\roee\appdata\local\arduino15\packages\esp8266\tools\xtensa-lx106-elf-gcc\3.1.0-gcc10.3-e5f9fec\xtensa-lx106-elf\include\c++\10.3.0\cmath:1927,
from c:\users\roee\appdata\local\arduino15\packages\esp8266\tools\xtensa-lx106-elf-gcc\3.1.0-gcc10.3-e5f9fec\xtensa-lx106-elf\include\c++\10.3.0\math.h:36,
from C:\Users\Roee\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\3.1.2\cores\esp8266/Arduino.h:34,
from C:\Users\Roee\AppData\Local\Temp\arduino\sketches\AA114658D2B46151BC441D22380B14D1\sketch\AdvancedWebServer_v5_ok.ino.cpp:1:
c:\users\roee\appdata\local\arduino15\packages\esp8266\tools\xtensa-lx106-elf-gcc\3.1.0-gcc10.3-e5f9fec\xtensa-lx106-elf\include\c++\10.3.0\bits\stl_algobase.h:230:5: note: previous declaration 'namespace std { }::min'
230 | min(const _Tp& __a, const _Tp& __b)
| ^~~
C:\Users\Roee\Documents\Arduino\AdvancedWebServer_v5_ok\AdvancedWebServer_v5_ok.ino: In function 'void handleRoot()':
C:\Users\Roee\Documents\Arduino\AdvancedWebServer_v5_ok\AdvancedWebServer_v5_ok.ino:71:15: error: overloaded function with no contextual type information
71 | min = sec / 60;
| ^~
C:\Users\Roee\Documents\Arduino\AdvancedWebServer_v5_ok\AdvancedWebServer_v5_ok.ino:72:16: error: invalid operands of types '' and 'int' to binary 'operator/'
72 | int hr = min / 60;
| ~~^~
C:\Users\Roee\Documents\Arduino\AdvancedWebServer_v5_ok\AdvancedWebServer_v5_ok.ino:94:23: error: invalid operands of types '' and 'int' to binary 'operator%'
94 | hr, min % 60, sec % 60, Tc);
| ~~^~
C:\Users\Roee\Documents\Arduino\AdvancedWebServer_v5_ok\AdvancedWebServer_v5_ok.ino: In function 'void roee_clk_run_always()':
C:\Users\Roee\Documents\Arduino\AdvancedWebServer_v5_ok\AdvancedWebServer_v5_ok.ino:194:15: error: invalid operands of types 'int' and '' to binary 'operator<'
194 | if (min_old < min) ){
| ~~~~^
C:\Users\Roee\Documents\Arduino\AdvancedWebServer_v5_ok\AdvancedWebServer_v5_ok.ino:194:22: error: expected primary-expression before ')' token
194 | if (min_old < min) ){
| ^

exit status 1

Compilation error: 'int min' conflicts with a previous declaration

sending code with global int, and bracket fix

/*
   Copyright (c) 2015, Majenko Technologies
   All rights reserved.

   Redistribution and use in source and binary forms, with or without modification,
   are permitted provided that the following conditions are met:

 * * Redistributions of source code must retain the above copyright notice, this
     list of conditions and the following disclaimer.

 * * Redistributions in binary form must reproduce the above copyright notice, this
     list of conditions and the following disclaimer in the documentation and/or
     other materials provided with the distribution.

 * * Neither the name of Majenko Technologies nor the names of its
     contributors may be used to endorse or promote products derived from
     this software without specific prior written permission.

   THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
   ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
   WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
   DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
   ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
   (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
   LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
   ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
   (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
   SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/

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

#ifndef STASSID
#define STASSID "Roee2"
#define STAPSK "0502147870"
#define Temp_array_size 10
#endif

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

const int analogInPin = A0;  // ESP8266 Analog Pin ADC0 = A0

//Roee for Temp

int Vo;
float R1 = 1586.1;
float logR2, R2, T, Tc, Tf;
float c1 = 1.630740587e-03, c2 = 1.387891336e-04, c3 = 17.90745831e-07,deg1=0;
int x=10,y2=10,temp_int,temp_int_old,sec_old,sec=0,min_old=0,min_count=1;
int Temp_array[Temp_array_size],Temp_array_place,min;
//

ESP8266WebServer server(80);

const int led = 13;

int sensorValue = 0;  // value read from the port A0
 
  

void handleRoot() {
  digitalWrite(led, 1);
  sec_old=sec;
  
  sec = millis() / 1000;
  min = sec / 60;
  int hr = min / 60;

 // Serial.println("handler");
  if (sec !=  sec_old) Serial.println("one sec");
  StreamString temp;
  temp.reserve(500);  // Preallocate a large chunk to avoid memory fragmentation
  temp.printf("\
<html>\
  <head>\
    <meta http-equiv='refresh' content='5'/>\
    <title>ESP8266 Demo</title>\
    <style>\
      body { background-color: #cccccc; font-family: Arial;font-size: 30; Helvetica, Sans-Serif; Color: #000088; }\
    </style>\
  </head>\
  <body>\
    <h2>Temperature Meter By Roee B</h2>\
    <p>Uptime: %02d:%02d:%02d</p>\
     <h1> Temperature: %2.1f C</h1>\
    <img src=\"/test.svg\" />\
  </body>\
</html>",
              hr, min % 60, sec % 60, Tc);
  server.send(200, "text/html", temp.c_str());
  digitalWrite(led, 0);
  sensorValue = analogRead(analogInPin);
  
}

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

void drawGraph() {
  String out;
  out.reserve(2600);
  char temp[70];
  Roee_temp_calc();
  out += "<svg xmlns=\"http://www.w3.org/2000/svg\" version=\"1.1\" width=\"400\" height=\"150\">\n";
  out += "<rect width=\"400\" height=\"150\" fill=\"rgb(250, 230, 210)\" stroke-width=\"1\" stroke=\"rgb(0, 0, 0)\" />\n";
  out += "<g stroke=\"black\">\n";
 // int y = rand() % 130;
  while (x<390)
  {
   temp_int =  int(round(Tc));
   int y=100;
   while (x<390){
    sprintf(temp, "<line x1=\"%d\" y1=\"%d\" x2=\"%d\" y2=\"%d\" stroke-width=\"1\" />\n", x, 100+temp_int_old, x + 10, 100 +temp_int);
  //  out += temp;
   x=x+10;
  }
  out += "</g>\n</svg>\n";

  server.send(200, "image/svg+xml", out);
  }
}

void setup(void) {
  pinMode(led, OUTPUT);
  digitalWrite(led, 0);
  Serial.begin(115200);
  WiFi.mode(WIFI_STA);
  WiFi.begin(ssid, password);
  Serial.println("");

  for (int j=0;j<Temp_array_size; j++)
  Temp_array[j]=0;

  // 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("/test.svg", drawGraph);
  server.on("/inline", []() {
    server.send(200, "text/plain", "this works as well");
  });
  server.onNotFound(handleNotFound);
  server.begin();
  Serial.println("HTTP server started");
}

void Roee_temp_calc()
{
  temp_int_old =  int(round(Tc));
  Vo = analogRead(analogInPin);
  R2 = R1 * (1023.0 / (float)Vo - 1.0);
  logR2 = log(R2);
  T = (1.0 / (c1 + c2*logR2 + c3*logR2*logR2*logR2));
  Tc = T - 273.15;
  Tf = (Tc * 9.0)/ 5.0 + 32.0; 
  deg1=Tc;
//  Serial.print("temp calc");

}

void roee_clk_run_always()
{
   //min = sec / 60;
  if (min_old < min) {
     Serial.print("one min ");
     Serial.print(min_count);
     Serial.print("  Temp:");
     Serial.println (temp_int);
    min_old= min;
    min_count++;
  }
  }
void Push_array_temp( int new_temperature) // push new value to array
{
     for (int j=1; j<Temp_array_size; j++)
     Temp_array[j+1] = Temp_array[j];
     Temp_array[0] = new_temperature;


}




void loop(void) {
  server.handleClient();
  roee_clk_run_always();
  MDNS.update();
 
}

type or paste code here

no in the new code I have deleted parenthesis

Thanks,
Roee

min might be reserved; for an AVR based board (I doubt other boards will differ)

#define min(a,b) ((a)<(b)?(a):(b))

Try to change min to e.g. minimum.

@sterretje has it right.

Why didn't you just read the error messages? The cause was right there.

THANKS you MAN!

another question on the working code.
Why the minutes count still doesn't work? (working just if I open HTML window, when I close it counting stops ?)

/*
   Copyright (c) 2015, Majenko Technologies
   All rights reserved.

   Redistribution and use in source and binary forms, with or without modification,
   are permitted provided that the following conditions are met:

 * * Redistributions of source code must retain the above copyright notice, this
     list of conditions and the following disclaimer.

 * * Redistributions in binary form must reproduce the above copyright notice, this
     list of conditions and the following disclaimer in the documentation and/or
     other materials provided with the distribution.

 * * Neither the name of Majenko Technologies nor the names of its
     contributors may be used to endorse or promote products derived from
     this software without specific prior written permission.

   THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
   ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
   WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
   DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
   ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
   (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
   LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
   ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
   (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
   SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/

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

#ifndef STASSID
#define STASSID "Roee2"
#define STAPSK "0502147870"
#define Temp_array_size 10
#endif

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

const int analogInPin = A0;  // ESP8266 Analog Pin ADC0 = A0

//Roee for Temp

int Vo;
float R1 = 1586.1;
float logR2, R2, T, Tc, Tf;
float c1 = 1.630740587e-03, c2 = 1.387891336e-04, c3 = 17.90745831e-07,deg1=0;
int x=10,y2=10,temp_int,temp_int_old,sec_old,sec=0,min_old=0,min_count=1;
int Temp_array[Temp_array_size],Temp_array_place,minutes;
//

ESP8266WebServer server(80);

const int led = 13;

int sensorValue = 0;  // value read from the port A0
 
  

void handleRoot() {
  digitalWrite(led, 1);
  sec_old=sec;
  
  sec = millis() / 1000;
  int min = sec / 60;
  int hr = min / 60;
 minutes= int(min);
 // Serial.println("handler");
  if (sec !=  sec_old) Serial.println("one sec");
  StreamString temp;
  temp.reserve(500);  // Preallocate a large chunk to avoid memory fragmentation
  temp.printf("\
<html>\
  <head>\
    <meta http-equiv='refresh' content='5'/>\
    <title>ESP8266 Demo</title>\
    <style>\
      body { background-color: #cccccc; font-family: Arial;font-size: 30; Helvetica, Sans-Serif; Color: #000088; }\
    </style>\
  </head>\
  <body>\
    <h2>Temperature Meter By Roee B</h2>\
    <p>Uptime: %02d:%02d:%02d</p>\
     <h1> Temperature: %2.1f C</h1>\
    <img src=\"/test.svg\" />\
  </body>\
</html>",
              hr, min % 60, sec % 60, Tc);
  server.send(200, "text/html", temp.c_str());
  digitalWrite(led, 0);
  sensorValue = analogRead(analogInPin);
  
}

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

void drawGraph() {
  String out;
  out.reserve(2600);
  char temp[70];
  Roee_temp_calc();
  out += "<svg xmlns=\"http://www.w3.org/2000/svg\" version=\"1.1\" width=\"400\" height=\"150\">\n";
  out += "<rect width=\"400\" height=\"150\" fill=\"rgb(250, 230, 210)\" stroke-width=\"1\" stroke=\"rgb(0, 0, 0)\" />\n";
  out += "<g stroke=\"black\">\n";
 // int y = rand() % 130;
  while (x<390)
  {
   temp_int =  int(round(Tc));
   int y=100;
   while (x<390){
    sprintf(temp, "<line x1=\"%d\" y1=\"%d\" x2=\"%d\" y2=\"%d\" stroke-width=\"1\" />\n", x, 100+temp_int_old, x + 10, 100 +temp_int);
  //  out += temp;
   x=x+10;
  }
  out += "</g>\n</svg>\n";

  server.send(200, "image/svg+xml", out);
  }
}

void setup(void) {
  pinMode(led, OUTPUT);
  digitalWrite(led, 0);
  Serial.begin(115200);
  WiFi.mode(WIFI_STA);
  WiFi.begin(ssid, password);
  Serial.println("");

  for (int j=0;j<Temp_array_size; j++)
  Temp_array[j]=0;

  // 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("/test.svg", drawGraph);
  server.on("/inline", []() {
    server.send(200, "text/plain", "this works as well");
  });
  server.onNotFound(handleNotFound);
  server.begin();
  Serial.println("HTTP server started");
}

void Roee_temp_calc()
{
  temp_int_old =  int(round(Tc));
  Vo = analogRead(analogInPin);
  R2 = R1 * (1023.0 / (float)Vo - 1.0);
  logR2 = log(R2);
  T = (1.0 / (c1 + c2*logR2 + c3*logR2*logR2*logR2));
  Tc = T - 273.15;
  Tf = (Tc * 9.0)/ 5.0 + 32.0; 
  deg1=Tc;
//  Serial.print("temp calc");

}

void roee_clk_run_always()
{
   //min = sec / 60;
  if (min_old < minutes) {
     Serial.print("one min ");
     Serial.print(min_count);
     Serial.print("  Temp:");
     Serial.println (temp_int);
    min_old= minutes;
    min_count++;
  }
  }
void Push_array_temp( int new_temperature) // push new value to array
{
     for (int j=1; j<Temp_array_size; j++)
     Temp_array[j+1] = Temp_array[j];
     Temp_array[0] = new_temperature;


}




void loop(void) {
  server.handleClient();
  roee_clk_run_always();
  MDNS.update();
 
}

type or paste code here

You only update minutes in your handleRoot() function. If that doesn't run, min_old and minutes never get updated so this if() statement will be false since they will be equal

Hi,
This still doesn't work.
I have updated it like this:

void handleRoot() {
  digitalWrite(led, 1);
  roee_clk_run_always();

same ..
clarify, the minutes on Serial is updated and sent out only if HTTP window is opened
See attached picture

so actual minutes is 12 while Serial print 4 (because I closed it and then reopen it)
meaning Serial only works while HTTP is open, while I want it to print minutes no matter if HTTP is open or HTTP is closed (from chrome browser)

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