Showing posts with label monitor. Show all posts
Showing posts with label monitor. Show all posts

ESP8266 Battery Voltmeter / Charge Controller ShutDown Reset Pi UPS Back Up Supply[OUT-DATED]


     
   //################################/ //####################################################################
   //##############################/   //#################################################_________ #########
   //#############################/   //=================================================//////////##########  
   //####################//Esp8266 Battery Manager ------------------                   //       //######@@##  
   //########################## WEMOS D1 MINI ##############-----                      // O O O //#######@@##  
   //###############################// for------###    ===============================//<<<<<<<//########@@##  
   //###################//UPS Back UP Power Supply for ######################################################  
   //#################### RASPBERRY PI 3   / SECURITY CAMERA PROJECT ########################################  
   //############################/ |WWWW| /##################################################################  
   //###########################/  \O_O/ ####################################################################  
   //# CAN BE USED AS A GENERAL PURPOSE BATTERY MONITOR / CHARGING ##########################################  
   //############# AFTER SOME MODIFICATIONS ############# NI-CD / LEAD ACID #################################  
   //#################################################### NOT LI-ION ########################################    
    
 //###################
///// OUTDATED //// Watch :https://www.youtube.com/watch?v=GTEyUZAViSA
 //###################
// ******************************************************************************************** // ***** IMPORTANT : rest of the details will be posted later // ******************************************************************************************** // ######################################################################### // #### I'll improve it as i learn more // ######################################################################### // PLEASE LIKE AND SUBSCRIBE // MY YOUTUBE CHANNEL // YOUTUBE.COM/CRAZYGUYOFFICIAL // Visit Blog for Sketch Updates and more Sketches and "things" // ######################################################################### #include <ESP8266WiFi.h> //################################# const char* ssid = "wubbadlubba"; const char* password ="dubdub420"; WiFiServer server(80); //################################# //### Charge Voltage Settings ##### //################################# float LoadOFF = 6.50 ; // Voltage at which Load will Turn OFF float LoadON = 10.00 ; // Voltage at which Load will Turn ON float ChargeOFF = 12.00 ; // Cut OFF Voltage at which Charging will Turn OFF float ChargeON = 9.60 ; // Voltage at which Charging will Turn ON //########################################### //### Voltage to ShutDown For Raspberry pi ## //########################################### float PiOFF = 7.50 ; // Voltage at which pi shutdown pin will Turn ON // telling the Pi to ShutDown //############################################# //###### PINS for Sensing and Switching ####### //############################################# byte ChrgS = 2; // D4 // Charging Switch Pin // using an NPN transistor and P-channel Mosfet byte LoadS = 5; // D1 // Load ON / OFF Pin byte PowerS = 4; // D2 // Power Sense to check if power is available or not //############################################## //### Pin for Rapberry pi Shutdown / Reset #### //############################################## byte StfdPin = 12 ; // D6 // Pin For signaling Pi to ShutDown // pi will use Gpio to read byte PiStsPin = 13 ; // D7 // Pin to see Pi's status // pi will use gpio to send byte PiRst = 14 ; // D5 // pin to reset pi using NPN transistor connected to RUN pad/pin on pi //###################################### //### ADC pin & Resistors Values ####### //###################################### float R1 = 47000.00; // resistance of R1 (47 K) float R2 = 6650.00; // resistance of R2 (6.65 K) byte analInput = A0; // ADC pin //############################################## //#### Variables used for Voltage Calculation ## //############################################## float Vout = 0.00; float Vin = 0.00; int Val = 0; //################################# //### Variables for Timers ######## //################################# unsigned long Secs = 0; // Secs Counter used to Turn OFF Charging int Time1 = 250; // Time in Seconds after which the Charging will Turn off // after reaching Cut off voltage unsigned long SecsTwo = 0; // Secs Counter two used to Turn ON Load byte Time2 = 250; // Time in Seconds after which the Load will Turn On // after reaching Load Turn On Voltage byte Time3 = 250; // Time in Seconds after which the Pi Will be Reset //******************************************************************************************* //** IMPORTANT *** For Larger Values Change Variable type to "int Time" instead of byte ** //******************************************************************************************* //################################ bool Charging = 0 ; // don't change these values bool LoadConnect = 0 ; // manually bool Power = 0 ; bool PiUp = 0 ; //################################ //############################################################################################### //############################################################################################### //################ SETUP START ################################################################## //############################################################################################### //############################################################################################### void setup() { //**** OUTPUT PINS ***** pinMode(StfdPin,OUTPUT); // Shutdown Signal Pin for Pi pinMode(PiRst, OUTPUT); // Reset Pin for Pi pinMode(ChrgS, OUTPUT); // Charging ON / OFF Pin pinMode(LoadS, OUTPUT); // Load ON / OFF Pin digitalWrite (ChrgS,HIGH); // Charging ON // npn transistor and P-channel mosfet Charging = 1 ; digitalWrite (StfdPin,LOW); // Keep Shutdown signal pin OFF digitalWrite (LoadS,LOW); // Keep LOAD OFF LoadConnect = 0 ; digitalWrite(PiRst, LOW); // Keep Pi Reset Pin OFF //**** INPUT PINS ***** pinMode(analInput, INPUT); // Adc analog read pin //voltage divider circuit for battery voltage pinMode(PiStsPin, INPUT) ; // Pin for Reading Pi Status using Pi's GPIO HIGH/LOW State pinMode(PowerS, INPUT) ; // Pin for Sensing Power from Charger / Adapter using npn transistor // and a voltage divider circuit Power =0; //##### Serial & WIFI Stuff ########### Serial.begin(115200); delay(10); Serial.println(); Serial.print("Connecting to "); Serial.println(ssid); WiFi.mode(WIFI_STA); WiFi.begin(ssid, password); while (WiFi.status() != WL_CONNECTED) { delay(500); Serial.println("."); } Serial.println("WiFi connected"); server.begin(); Serial.println("Waiting for the IP .."); delay(5000); Serial.println(WiFi.localIP()); } //############################################################################################### //############################################################################################### //################ SETUP END #################################################################### //############################################################################################### //############################################################################################### //############################################################################################## //############################################################################################## //################ Function for Voltage Calculation ############################################ //############################################################################################## //############################################################################################## void VoltageCalc() { delay(1000); Val = analogRead(analInput); // reads Analog input using A0 delay(1000); //for maintaining the speed of the output in serial monitor Vout = (Val * 3.40/ 1024.00); // formula for calculating voltage out from the Divider circuit Vin = Vout / (R2 / (R1 + R2)); // formula for calculating Battery voltage if (Vin < 0.25) // set Voltage to Zero if reading less than .50 V { Vin = 0.00; } Serial.println("################"); Serial.println("Battery Voltage: "); Serial.println(Vin); } //############################################################################################### //############################################################################################### //################ LOOP BEGINS ################################################################## //############################################################################################### //############################################################################################### void loop() { //delay(1000); // for maintaining the speed of the output in serial monitor VoltageCalc(); // Calculate Battery Voltage //########################################## //## NO POWER ### TURN LOAD OFF ### Pi OFF # //########################################## if (!Power) // **** IF Power is NOT Available **** { digitalWrite(ChrgS,HIGH); // Turn ON Charging Charging = 1 ; if(LoadConnect) // and Load is Connected { PiUp = !digitalRead(PiStsPin); // Set Pi's Status if(Vin <= PiOFF && PiUp) // IF Voltage is less than PiOFF // and pi is running { Serial.println("it has been an Honour Pi"); digitalWrite(StfdPin,HIGH); // Turn Signal Pin HIGH so, Pi can shutdown properly } if(Vin <= LoadOFF && !PiUp) // if Voltage is less than LoadOFF { Serial.println ("Turned Load OFF "); // Turn Load OFF digitalWrite(LoadS, LOW); LoadConnect = 0; } } Secs = SecsTwo = millis()/1000; // Keep BOTH Timers Updated while no power Power = !digitalRead(PowerS); // Check for Power Availability } //################################################# //## YES POWER ## TURN CHARGING / LOAD ON / OFF ### //################################################# //################################# else // **** IF Power is Available ***** { //################################# //################################# //##### TURN CHARGING OFF ######### //################################# Power = !digitalRead(PowerS); // Check for Power // the "!"/not inverts the output High means OFF Low means ON if (Charging) // IF charging is ON { if(Vin >= ChargeOFF) //**** IF Voltage has Reached Cut off/ ChargeOFF Value **** { Serial.println ("CHARGE OFF Voltage Reached"); Serial.println ("will turn off charging after time up" ); if(millis()/1000 -Secs > Time1 ) // Seconds After which charging will turn off { Serial.println ("Turned Charging OFF "); digitalWrite(ChrgS, LOW); // Turn OFF Charging Charging = 0; } } else // if charging is ON but voltage has not reached Cut OFF { Secs = millis()/1000; // Keep Timer1 updated Serial.println("Battery is not fully charged yet "); } } //########################################## //######### TURN CHARGING ON ############### //########################################## else // Power is Available but Charging is OFF { if(Vin <= ChargeON ) // and if Voltage has dropped to ChargeON value { Serial.println ("Turned Charging ON "); digitalWrite(ChrgS, HIGH); // Turn Charging ON Charging = 1 ; } Secs = millis()/1000; // update timer 1 // keep updating it while charging is off } //########################################## //######### TURN LOAD ON ################### //########################################## //################################### if(!LoadConnect) // Power is Available but Load is OFF { //################################### if(Vin >= LoadON) // if Voltage is above Load ON { if(millis()/1000 -SecsTwo > Time2 ) // Seconds After the Load ON Voltage is reached { Serial.println ("Turned Load ON "); digitalWrite(LoadS, HIGH); // Turn Load ON digitalWrite(StfdPin,LOW); // Keep Signal Pin OFF LoadConnect = 1 ; } } else { Serial.println("Waiting for Battery to Reach Load ON Voltage"); SecsTwo = millis()/1000; // Keep Timer Two Updated while Voltage Lower than Load ON } } //################################################# else // else if Power is Available and Load is Connected { //################################################# PiUp = !digitalRead(PiStsPin); // Set Pi's Status digitalWrite(StfdPin,LOW); // Turn Signal Pin LOW if(!PiUp && Vin >= PiOFF) // IF Pi is NOT UP then { Serial.println("Pi signal ON Trying to Reset Pi"); if(millis()/1000 -SecsTwo > Time3) // Count till Time 3 // maybe it's booting up { Serial.println("Giving a Shock to Pi "); digitalWrite(PiRst,HIGH); // Turn PiRst Pin ON delay(500); digitalWrite(PiRst,LOW); // Turn PiRst Pin OFF SecsTwo = millis()/1000; } } else // if power available and load connected and pi is up { SecsTwo = millis()/1000; // Keep Timer Two Updated while Load ON and PI is UP digitalWrite(StfdPin,LOW); // keep signal pin off Serial.println("OK "); } } } //################################## //##### SERIAL PRINT STATUS ######## //################################## if (Power) { Serial.println("POWER IS AVAILABLE"); if (Charging) { Serial.println ("Charging ON"); } else { Serial.println ("Charging OFF"); } } else { Serial.println("NO POWER AVAILABLE"); } if (LoadConnect) { Serial.println ("Load ON"); if(PiUp) { Serial.println("Pi is ON"); } else { Serial.println("Pi Is OFF"); } } else { Serial.println ("Load OFF"); } Serial.println("################"); //################################## //### HTML WebPage ################# //################################## sendHtml(); } //#################################################################################### //##################### END OF LOOP ################################################## //#################################################################################### //################################# //#### Function for HTML ########## //################################# void sendHtml() { WiFiClient client = server.available(); if (client) { Serial.println("New client"); boolean blank_line = true; while (client.connected()) { if (client.available()) { char c = client.read(); if (c == '\n' && blank_line) { client.println("HTTP/1.1 200 OK"); client.println("Content-Type: text/html"); client.println("Connection: close"); client.println(); client.println("<!DOCTYPE HTML>"); client.println("<html>"); client.println("<head><meta http-equiv='refresh' content='2'/></head><body><h1>ESP8266 Battery Manager Ver: 1.0</h1>"); client.println("<h2>AnalogIN :"); client.println(Val); client.println("</h2>"); client.println("<h2>Vout :"); client.println(Vout); client.println("V</h2>"); client.println("<h2>Battery Voltage :"); client.println(Vin); client.println("V</h2>"); client.println("<br />"); client.println("<h1>Current States </h1>"); client.println("<br />"); client.println("<h3>Charging:>>> "); if(Power) { if(Charging) { client.println("ON </h3>"); } else { client.println("OFF </h3>"); } } else { client.println("NO POWER </h3>"); } client.println("<h3>Load:>>>"); if(LoadConnect) { client.println("ON </h3>"); client.println("<h3>Pi Status:>>>"); if(PiUp) { client.println("ON </h3>"); } else { client.println("OFF </h3>"); } } else { client.println("OFF </h3>"); } client.println("<br />"); client.println("<br />"); client.println("<br />"); char LinkOne[]= "https://youtube.com/crazyguyofficial"; client.println("<h3><a href="); client.print(LinkOne); client.print(">CHANNEL</a></h3>"); char LinkTwo[]= "https://amkdiyprojects.blogspot.com"; client.println("<h3><a href="); client.print(LinkTwo); client.print(">BLOG</a></h3>"); client.println("</body></html>"); break; } if (c == '\n') { blank_line = true; } else if (c != '\r') { blank_line = false; } } } delay(1); client.stop(); // closing the client connection Serial.println("Client disconnected."); } }

Esp8266 Wemos D1 Mini Serial to Wifi Html WebServer Monitor for Arduino Smart Grow Box Controller [OUT-DATED]

 /* #########################################################################  
   #################### Esp8266 Serial to WiFi Monitor #####################  
   ########################## WEMOS D1 MINI ################################  
   ############################### for #####################################  
   ################### ARDUINO NANO SMART GROW CONTROLLER ##################  
   #################                              ##########################  
   ############################ |WWWW| #####################################  
   ############################ \O_O/ ######################################  
   #  CAN BE USED AS A GENERAL PURPOSE MONITOR FOR ANYTHING WITH A TX PIN ##  
   #############        AFTER SOME MODIFICATIONS        ####################  
 */  
     
   
   
 /* #########################################################################  
 I'll improve it as i learn more  
  #########################################################################  
 // PLEASE LIKE AND SUBSCRIBE   
 // MY YOUTUBE CHANNEL   
 // YOUTUBE.COM/CRAZYGUYOFFICIAL  
 // Visit Blog for Sketch Updates and more Sketches and "things"  
   
   
 // Set Port forward from your router to this Webserver at port 80  
 // to monitor it from anywhere**  
   
 // This server is not secure   
 // controlling things should NEVER be done using   
 // an UN-encrypted webserver like this  
 // It's only good for Monitoring   
 // Subscribe to my channel for updates for this sketch   
 // and other sketches related to this project   
 // because i'll add more things to it gradually   
   
  #########################################################################  
  #########################################################################  
   
   
 */  
   
 #include <ESP8266WiFi.h>  // Version 1.0.0  
 #include <SoftwareSerial.h>  // Version 1.0.0
   
   
   
 const char* ssid = "SQUANCHY01";  
 const char* password ="c137gsasotf";  
   
   
   
   
   
   
   
 char Time[9];           // Character Arrays or C-strings   
 char Day;             // size should be the total number of Chars to be stored +1 for null char  
 char Date[3];  
 char Mon[3];  
 char Year[5];  
 char Status[13];  
 char Temp1[6];  
 char Temp2[6];  
 char Hum[6];  
   
 unsigned long Secs = 0;   
   
 bool newData = 0;  
 bool err =1;  
   
 bool Lsts =0;  
 bool Csts =0;  
 bool Hsts =0;  
 bool Fsts =0;  
 bool Ssts =0;  
 bool DHTerr=0;  
 bool RTCerr=0;  
   
 WiFiServer server(80);  
   
 SoftwareSerial swSer(D1, D2, false, 256);   // "swSer can be changed it will be the name for the Software Serial   
                        // Software Serial Library Enables Esp8266's GPIO D1 and D2   
                        // to be used as Rx and Tx pins RESPECTIVELY   
                        // ONLY Rx is used and is connected to the Tx of a 5V Arduino Nano   
 void setup() {                // using a Voltage Divider circuit 1K and 2K Resistors   
                        // And Ground of esp to Ground of Arduino   
   
   
 Serial.begin(115200);             // This is the baud rate for ESP's Serial at USB which can be viewed in Arduino IDE Serial monitor  
    
 swSer.begin(9600);              // This is the baud rate for esps Software serial at pins D1 and D2 so it can communicate with arduino   
                        // it's slow because of Arduino Nano's slow speed as compared to Esp  
                        // can change the name swSer from above  
 delay(10);  
   
    
    
 Serial.println();  
    
 Serial.print("Connecting to ");  
    
 Serial.println(ssid);  
    
     
     
 WiFi.mode(WIFI_STA);           
                       
 WiFi.begin(ssid, password);  
    
    
    
    
 while (WiFi.status() != WL_CONNECTED)   
    
  {  
      
  delay(500);  
     
  Serial.print(".");  
    
  }  
    
    
  Serial.println("");  
    
  Serial.println("WiFi connected");  
    
    
  server.begin();  
    
  Serial.println("Waiting for the IP Add...");  
    
  delay(5000);  
    
    
  Serial.println(WiFi.localIP());  
   
  }  
   
   
 /*##############################################################################################  
  ###############################################################################################  
  ################ SETUP END ####################################################################  
  ###############################################################################################  
  */  
   
   
   
   
   
   
   
 /*##############################################################################################  
  ###############################################################################################  
  ################ LOOP BEGINS ##################################################################  
  ###############################################################################################  
  */  
   
   
 void loop()   
 {    
  char data[53];  
  byte i = 0 ;  
  byte x = 0 ;  
    
  if (swSer.available() > 0 )   
   
  {    
  char Z = swSer.read();  
     
   if(Z=='Z')   // match first Character to check "validity"   
   {        // and this letter 'Z' is not stored in the array below   
   
   newData=1;  
   Secs=millis()/1000;  
    
    for(i= 0; i< 52; )   
      
    {  
     data[i] = swSer.read();  
       
     i++;  
       
     data[i] = '\0';  
    }  
   
    
    for(i=0; i<52;)  
    {                // serial print to arduino ide monitor via usb,all the chars stored in data array  
     Serial.print("char number: "); // and print char number the INDEX number starting from zero   
                    // the actual first char is the Letter "Z' which is not stored  
     Serial.println(i);  
   
     Serial.println(data[i]);                
    
     i++;         
    }  
    
   }  
  else  
  {  
   err=1;  
  }  
  }  
   
   
 //############# GET TIME #######################################################################  
   
  if(newData)  
  {  
                       // get time from the data array   
   for( i = 0; i < 8; )   
   {   
    Time[i] = data[i];  
    
    i++;   
     
   }  
   
   Serial.print("Time :");   
   
   Serial.println(Time);           // serial print all the chars stored in the time array   
    
    
 //############# GET DAY OF THE WEEK #############################################################  
    
   if( data[8]=='W' )   
    
   {  
    err=0;  
    Day = data[9];  
     
   
   Serial.print("Day :");   
   
   Serial.println(Day);           // serial print all the chars stored in the day array   
   }  
   else  
   {  
   err=1;   
   }  
   
 //############# GET DATE #######################################################################  
   
   if(data[10]=='D')  
   {  
    err=0;   
    x=0;  
    for( i = 11; i < 13; )   
    {  
     Date[x] = data[i];  
     i++;   
     x++;  
    }  
   
    Serial.print("Date :");   
   
    Serial.println(Date);         // serial print all the chars stored in the Date array   
   }  
   else  
   {  
    err=1;   
   }  
   
   
   
 //############# GET MONTH #######################################################################  
   
   
   if(data[13]=='M')  
   {  
    err=0;   
    x=0;  
    for( i =14 ; i < 16; )   
    {  
     Mon[x] = data[i];  
     i++;   
     x++;  
    }  
     
    Serial.print("Month :");   
   
    Serial.println(Mon);          // serial print all the chars stored in the month / mon array   
   }  
   else  
   {  
    err=1;   
   }  
   
 //############# GET YEAR #######################################################################  
   
   if(data[16]=='Y')  
   {  
    err=0;   
    x=0;  
    for( i = 17; i < 21; )   
    {  
     Year[x] = data[i];  
     i++;   
     x++;  
    }  
   
    Serial.print("Year :");   
   
    Serial.println(Year);         // serial print all the chars stored in the Year array   
    
   }  
   else  
   {  
    err=1;   
   }  
    
    
 //############# GET STATUS #######################################################################  
   
   if(data[21]=='L')  
   {  
    err=0;   
    x=0;  
    for( i = 22; i < 34; )   
    {  
     Status[x] = data[i];  
     i++;   
     x++;  
    }  
    
    Serial.print("Status :");   
   
    Serial.println(Status);       // serial print all the chars stored in the Status array   
   }  
   else  
   {  
    err=1;  
   }  
   
    
 //############# GET T1 ###########################################################################  
   
   if(data[34]=='t')  
   {  
    err=0;   
    x=0;  
    for( i = 35; i < 40; )   
    {  
     Temp1[x] = data[i];  
     i++;   
     x++;  
    }  
   
    Serial.print("Temp 1 :");   
   
    Serial.println(Temp1);    // serial print all the chars stored in the temperature / temp1 array   
   }  
   else  
   {  
    err=1;   
   }  
   
   
 //############# GET Hum #######################################################################  
   
   
   if(data[40]=='h')  
   {   
    err=0;  
    x=0;  
    for( i = 41; i < 46; )   
    {  
     Hum[x] = data[i];  
     i++;   
     x++;  
    }  
   
    Serial.print("Humidity :");   
   
    Serial.println(Hum);    // serial print all the chars stored in the Humidity / Hum array   
   }  
   else  
   {  
    err=1;   
   }  
   
 //############# GET T2 #######################################################################  
   
   
   if(data[46]=='r')  
   {   
    err=0;  
    x=0;  
    for( i = 47; i < 52; )   
    {  
     Temp2[x] = data[i];  
     i++;   
     x++;  
    }  
    
    Serial.print("Temp2 :");   
   
    Serial.println(Temp2); // serial print all the chars stored in time array   
   }  
   else  
   {  
    err=1;   
   }  
    
  newData=0;  
   
 }  
   
   
  setStatus();  
    
  sendHtml();  
    
    
   if(millis()/1000 -Secs > 30 )  
   {  
   Serial.println("Resetting Arrays");  
   Serial.println(Secs);  
   ResetArrays();  
   Secs=millis()/1000;  
   }   
    
    
    
    
   
 }   
   
  //####################################################################################  
  //##################### END OF LOOP #######################################  
  //####################################################################################  
   
   
   
 void setStatus()  
 {  
  if(!err)  
  {  
  Lsts=Status[0]-'0';    
  Csts=Status[2]-'0';   
  Hsts=Status[4]-'0';  
  Fsts=Status[6]-'0';  
  Ssts=Status[8]-'0';  
  DHTerr=Status[10]-'0';  
  RTCerr=Status[11]-'0';  
   
  }  
   
   
 }  
   
   
   
 void sendHtml()  
 {  
   
  WiFiClient client = server.available();  
    
  if (client)   
  {  
   Serial.println("New client");  
   boolean blank_line = true;  
     
   while (client.connected())   
   {  
    if (client.available())   
    {  
     char c = client.read();  
       
     if (c == '\n' && blank_line)   
     {  
      client.println("HTTP/1.1 200 OK");  
      client.println("Content-Type: text/html");  
      client.println("Connection: close");  
      client.println();  
      
         
       
     
      client.println("<!DOCTYPE HTML>");  
      client.println("<html>");  
      client.println("<head><meta http-equiv='refresh' content='5'/></head><body><h1>Esp8266 Serial to Wifi Monitor Ver: 1.0</h1>");  
        
      client.println("<h2>>>>> ---- Time :");  
      client.println(Time);  
      client.println("--<<< >>> ---- Day : ");  
      client.println(Day);   
      client.println("--<<< >>> ---- Date : ");  
      client.println(Date);  
      client.println("-");  
      client.println(Mon);  
      client.println("-");  
      client.println(Year);  
      client.println("---- <<<<<");  
      client.println("</h2>");  
      client.println("<br />");  
   
      client.println("<h2>Temp 1 :");  
      client.println(Temp1);  
      client.println("\260C</h2>");  
       
      client.println("<h2>Temp 2 :");  
      client.println(Temp2);  
      client.println("\260C</h2>");  
       
      client.println("<h2>Humidity :");  
      client.println(Hum);  
      client.println("%</h2>");  
       
      client.println("<br />");  
   
      client.println("<h1>Current States of Switches</h1>");  
    
      client.println("<br />");  
        
      client.println("<h3>LIGHT:>>> ");  
       if(!err)  
       {  
        if(Lsts)  
        {  
        client.println("ON </h3>");  
        }  
        else  
        {  
        client.println("OFF </h3>");  
        }  
       }  
       else  
       {  
        client.println("UNKNOWN </h3>");  
       }  
        
        
        
      client.println("<h3>COOLER:>>>");  
         
         
       if(!err)  
       {   
        if(Csts)  
        {  
        client.println("ON </h3>");  
        }  
        else  
        {  
        client.println("OFF </h3>");   
        }  
       }  
       else  
       {  
       client.println("UNKNOWN </h3>");  
       }  
        
        
        
      client.println("<h3>HEATER:>>>");  
        
       if(!err)  
       {  
        if(Hsts)  
        {  
        client.println("ON </h3>");  
        }  
        else  
        {   
        client.println("OFF </h3>");  
        }  
       }  
       else  
       {  
       client.println("UNKNOWN </h3>");  
       }  
        
        
        
      client.println("<h3>FAN:>>>");  
        
         
       if(!err)  
       {  
        if(Fsts)  
        {  
        client.println("ON </h3>");  
        }  
        else  
        {  
        client.println("OFF </h3>");    
        }  
       }  
       else  
       {  
       client.println("UNKNOWN </h3>");  
       }  
        
        
      client.println("<h3>HUMIDIFIER:>>>");  
         
       if(!err)  
       {  
        if(Ssts)  
        {  
        client.println("ON </h3>");  
        }  
        else  
        {  
        client.println("OFF </h3>");  
        }  
       }  
       else  
       {  
       client.println("UNKNOWN </h3>");  
       }  
        
        
      client.println("<br />");  
   
        
   
         
         
         
      client.println("<h4>DHT Err:>>>");  
       if(!err)  
       {  
        if(DHTerr)  
        {  
        client.println("TRUE </h4>");  
        }  
        else  
        {  
        client.println("FALSE </h4>");   
        }  
       }  
       else  
       {  
       client.println("UNKNOWN </h4>");  
       }  
        
        
        
        
      client.println("<h4>RTC Err:>>>");  
         
       if(!err)  
       {  
        if(RTCerr)  
         {  
         client.println("TRUE </h4>");  
         }  
        else  
        {  
        client.println("FALSE </h4>");   
        }  
       }  
       else  
       {  
       client.println("UNKNOWN </h4>");  
       }  
        
      client.println("<br />");  
   
      client.println("<h4>Serial Read Error:>>>");  
       if(err)  
       {  
       client.println("TRUE ----OH JEEZ </h4>");  
       }  
       else  
       {  
       client.println("FALSE </h4>");  
       }       
        
        
      char LinkOne[]= "https://youtube.com/crazyguyofficial";  
      client.println("<h3><a href=");  
      client.print(LinkOne);  
      client.print(">CHANNEL</a></h3>");  
        
      char LinkTwo[]= "https://amkdiyprojects.blogspot.com";  
      client.println("<h3><a href=");  
      client.print(LinkTwo);  
      client.print(">BLOG</a></h3>");  
        
      client.println("</body></html>");     
      break;  
      
       
     }  
       
        
     if (c == '\n')   
     {  
     blank_line = true;  
     }  
     else if (c != '\r')   
     {  
     blank_line = false;  
     }  
      
      
    }  
   }   
     
     
     
  delay(1);  
  client.stop();  // closing the client connection  
   
  Serial.println("Client disconnected.");  
     
  }  
 }  
   
   
 void ResetArrays()  
 {  
  //Serial.flush();   
  err=1;  
 // data[0]  ='\0';  
  Time[0]  ='\0';             // Character Arrays or C-strings   
  Day    ='\0';             // size should be the total number of Chars to be stored +1 for null char  
  Date[0]  ='\0';  
  Mon[0]  ='\0';  
  Year[0]  ='\0';  
  Status[0] ='\0';  
  Temp1[0] ='\0';  
  Temp2[0] ='\0';  
  Hum[0]  ='\0';  
 }