Zero Municipal Water Toilet Code

// Following code is based on the furnace and water heater code so a lot of instructions are commented out. I may enable those functions later

// You don't have to worry about running out of memory like on an Arduino Uno. It's not pretty but it works.

// All my code is uploaded wirelessly so network SSID and password are not needed here. They are in the Basic OTA sketch which must be loaded over USB first. See 2. below.

// Make sure and use old Arduino IDE Software version 1.6.11 (for sure, it's what I use) or earlier (possibly). Latest version doesn't work.

// Old versions can be downloaded here: https://www.arduino.cc/en/Main/OldSoftwareReleases#previous

// Also have to install an older version of Python 2.7.13 as per beginner instructions in 2. below. NOT latest Python version. Doesn't work.

// Also need to load all the libraries listed at the top of the code into Arduino IDE.

//

// The following Nodemcu 12E (LoLin V3) code includes lines for Over the Air Programming,

// LED control from web page, DS32331 Real Time Clock display, DHT22 temp and humidity display, DS18B20 temp display,

// MCP23017 digital I/O expander with button input and LED output and 4 channel relay board

// Relay power is 5 V so LoLin Nodemcu 12E has a VU output which is V USB and is 5 V

// Analog input from photo resistor will be used to detect flame ON LED on gas furnace.

// Most of these functions are used for gas furnace and water heater control currently using Arduino Uno. Saves $60-$80 per month.

// To be replaced with this ESP8266. MCP23017 outputs are connected to a relay board for furnace and water heater control.

// Code is cut and pasted from many sources especially examples from included library directories

//

// Screenshot of html web page coming from the board is here:

// https://sites.google.com/site/nodemcu12e/

//

// Picture of setup and wiring is here:

// https://sites.google.com/site/nodemcu12e/

//

// Nodemcu 12E board spans across the edges of two 17X10 protoboards so lots of pin locations are available plus isolated pin area

// for mounting Real Time Clock DS3231, DHT22 temp and humidity, input button and photoresistor and DS18B20 connections.

// Third board is for MCP23017. All are mounted on a piece of plastic.

//

// For beginners I followed these videos and website instructions in order.

//

// 1. Getting started. You have to add esp8266 to list of boards in Arduino IDE.

// Put a 220 ohm resistor in series with the LED NOT directly on output as shown.

// https://m.youtube.com/watch?v=NEo1WsT5T7s

//

// 2. Wireless Over The Air (OTA) programming setup. Serial monitor won't work after this.

// https://m.youtube.com/watch?v=ZVA1pV6WUQg //

// 3. Control LED from a web page. Need to learn some html

// http://internetofthinking.blogspot.ca/2015/12/control-led-from-webserver-using.html

//

// 4. To create a web page to store images and program backup:

// http://youtu.be/vgpbGjXRObE

#include <ArduinoOTA.h> //*** Enables OTA programming. 1 of 3 lines

WiFiServer server(80); //Used for WiFi Server

#include <RtcDS3231.h> //Real Time Clock library on I2C for DS3231. pin D1 is SCL, pin D2 is SDA

#include <OneWire.h> //Used for DS18B20 temp sensors https://datasheets.maximintegrated.com/en/ds/DS18B20.pdf

#include <DallasTemperature.h> //Used for DS18B20 temp sensors. Run Simple DS18B20 from DallasTemperature first to find sensor addresses.

//Run Example Simple.pde from DallasTemperature first to find sensor addresses.

#include <Wire.h> //I2C library Used for Real Time Clock and MCP23017 I/O expander. Same two wires.

#include <RtcDS3231.h> //RTC library

// #include "Adafruit_MCP23017.h" //MCP23017 I/O expander see library example. Note: 10K resistor VDD pin 9 to pin 18.

// Note: pin 9 VDD=3.3V power pin 10 VSS=Ground

//pin 12 is SCL, pin 13 is SDA pins 15,16,17 grounded to set chip address to 0

//MCP23017 datasheet: https://drive.google.com/file/d/0ByB7Piqn39AAUS1uU2RVRGctZVk/view?usp=sharing

// #include <DHT.h> //Used for DHT22 temp and humidity measurement. Note I am using Adafruit library version 1.0.0 NOT newer versions.

// #define DHT1PIN D5 //What pin temp sensor 1 connected to D5 = 14

// #define DHTTYPE DHT22 //DHT 22 temp sensor (AM2302)

// DHT dht1(DHT1PIN, DHTTYPE, 20); //NOTE!!! 20 is needed to adjust timing for higher speed ESP8266. See DHTtester.ino example in 1.0.0 library.

#define ONE_WIRE_BUS D5 //Define pin the one wire bus is on

// Adafruit_MCP23017 mcp; // MCP23017 I/O expander gives 16 more digital I/O to board using I2C

RtcDS3231<TwoWire> Rtc(Wire); // Real Time clock

int yvalue, rvalue, input4, analoginput, counter, wkday, offtimewh;

// int autowh; // water heater auto mode

int RL1FURNACEOFF = 8; // relay 1 furnace OFF output 8 on MCP23017

int RL2FURNACELO = 9; // relay 2 furnace LOW output 9 on MCP23017

int RL4HEATEROFF = 11; // relay 4 water heater on or off relay ON for heater OFF

int DeicerOFF = 1; // Deicer status bit

int lastSecond = -1; // set last second to impossible number so it prints right away then every second

int lastSecond1 = -1; // used to reset alert only once per second

int currentmillis = 0;

int previousmillis = 0;

String request, timedate, Month, Day, Hour, Minute, Second, dow, barrel, tank;

String insidetemp, humidity, furnaceLED, basementtemp, outsidetemp, tempdata;

float t1, temp1, t2, temp2, h1, prevh1, prevt1, amps;

int alertsent_fail, alertsent_data, resetalert;

// Furnace Variables

int WellpumpON = 0;

int TankpumpON = 0;

int furnaceONvalue = 0; // value read from the furnace on sensor = analog input

int off_flag; // furnace off flag

int onoffval = 0;

int furnaceONtime = 0;

int furnaceONrecord = 0;

int offtime, furnacelo;

int furnaceOFF; // furnace status bit

int furnaceOFFtime = 0;

int furnaceOFFrecord = 0;

int furnaceOFFflag = 0;

int serialreport = 0;

int ONpercent = 0;

float degreesC, temp1raw, temp2raw, IATvalue, Kwhtotal, alertreset;

float lowsetpoint = 19.0;

int IATaverage,a1,a2,a3,a4,a5,a6,a7,a8,wellwater, welltimer, filltime, tankpumpON, fillbit;

int recordbit = 1.0;

int seconds, timeNOW, timeLAst;

int ONhour =0;

int ONtotal = 0;

float ONtemp, OFFtemp, ONmonths;

String ONtempstring, StrfurnaceONtime, StrfurnaceONrecord, StrfurnaceOFFtime, StrfurnaceOFFrecord, StrONtotal;

//record ONpercent every hour

int ONpct0; int ONpct1; int ONpct2; int ONpct3; int ONpct4; int ONpct5; int ONpct6; int ONpct7; int ONpct8; int ONpct9;

int ONpct10; int ONpct11; int ONpct12; int ONpct13; int ONpct14; int ONpct15; int ONpct16; int ONpct17; int ONpct18; int ONpct19;

int ONpct20; int ONpct21; int ONpct22; int ONpct23;

int ONtotal0; int ONtotal1; int ONtotal2; int ONtotal3; int ONtotal4; int ONtotal5; int ONtotal6; int ONtotal7; int ONtotal8; int ONtotal9;

int ONtotal10; int ONtotal11; int ONtotal12; int ONtotal13; int ONtotal14; int ONtotal15; int ONtotal16; int ONtotal17; int ONtotal18; int ONtotal19;

int ONtotal20; int ONtotal21; int ONtotal22; int ONtotal23;

int ONhour0; int ONhour1; int ONhour2; int ONhour3; int ONhour4; int ONhour5; int ONhour6; int ONhour7; int ONhour8; int ONhour9;

int ONhour10; int ONhour11; int ONhour12; int ONhour13; int ONhour14; int ONhour15; int ONhour16; int ONhour17; int ONhour18; int ONhour19;

int ONhour20; int ONhour21; int ONhour22; int ONhour23;

// Ultrasonic variables

int trig = D4;// common trigger output

int ultrasonics_read;

int Barrelecho = D0;

int Barrelduration; int Barreldistance; int Barrel_level=100; int Barrel_full; // initialize level to 100% so pumps don't start after upload - only reads level every minute

int Tankecho = D8;

int Tankduration; int Tankdistance; int Tank_level=100; // initialize level to 100% so pumps don't start after upload - only reads level every minute

// End of Furnace Variables

OneWire oneWire(ONE_WIRE_BUS); //Used for DS18B20 temp sensors

DallasTemperature sensors(&oneWire); //Used for DS18B20 temp sensors

DeviceAddress Sens1, Sens2; //Used for DS18B20 temp sensors

// Alert Setup

const char *host = "maker.ifttt.com";

const char *privateKey = "************************************"; // get personal private key from ifttt.com applet setup

String url = "/trigger/Home_Data/with/key/************************************";

// End of Alert Setup

void setup() {

ArduinoOTA.begin(); //*** Enables OTA programming. 2 of 3 lines

server.begin();

// dht1.begin();

// mcp.begin(); // use default address 0 on MCP23017 I/O expander

pinMode(D0, INPUT); // Initialize D1 pin as an input Barrel Ultrasonic echo on Nodemcu 12E board

pinMode(D4, OUTPUT); // Initialize D4 pin as an output Ultrasonic trigger on Nodemcu 12E board

pinMode(D6, OUTPUT); // Initialize D6 pin as an output YELLOW LED Well pump on Nodemcu 12E board

pinMode(D7, OUTPUT); // Initialize D7 pin as an output RED LED Tank pump on Nodemcu 12E board

pinMode(D8, INPUT); // Initialize D8 pin as an input Tank Ultrasonic echo on Nodemcu 12E board

// mcp.pinMode(4, INPUT); // test mcp input with button. Grounds pin for input

// mcp.pullUp(4, HIGH); // turn on a 100K pullup internally. input switch grounds LOW for input

// mcp.pinMode(5, OUTPUT); // Initialize mcp 5 pin as an output GREEN LED on MCP23017

// mcp.pinMode(6, OUTPUT); // Initialize mcp 6 pin as an output YELLOW LED on MCP23017

// mcp.pinMode(7, OUTPUT); // Initialize mcp 7 pin as an output RED LED on MCP23017

// mcp.pinMode(RL1FURNACEOFF, OUTPUT); // Initialize mcp 8 pin as furnace OFF output Relay 1 on MCP23017

// mcp.pinMode(RL2FURNACELO, OUTPUT); // Initialize mcp 9 pin as furnace LOW output Relay 2 on MCP23017

// mcp.pinMode(10, OUTPUT); // Initialize mcp 10 pin as an output Relay 3 on MCP23017 - not used

// mcp.pinMode(RL4HEATEROFF, OUTPUT); // Initialize mcp 11 pin as water heater output Relay 4 on MCP23017

// mcp.digitalWrite(8, HIGH); // Since relays are active LOW write High to outputs initially.

// mcp.digitalWrite(9, HIGH); // Since relays are active LOW write High to outputs initially.

// mcp.digitalWrite(10, HIGH); // Since relays are active LOW write High to outputs initially.

// mcp.digitalWrite(11, HIGH); // Since relays are active LOW write High to outputs initially.

//

// Initialize relay outputs for pumps to HIGH since LOW activates the relay

digitalWrite(D6, HIGH); // Well pump

digitalWrite(D7, HIGH); // Tank pump

Rtc.Begin(); //Starts I2C

// Start up the DS18B20 library and set temp resolution 11 bits equals .125C

sensors.begin();

sensors.getAddress(Sens1, 0);

sensors.setResolution(Sens1, 11);

sensors.getAddress(Sens2, 1);

sensors.setResolution(Sens2, 11);

// Uncomment next two lines to set RTC if required - after setting clock make sure and upload commented version again or time will be reset on reboot

// RtcDateTime t = RtcDateTime(18, 4, 5, 11, 59, 0); //set date and time NO leading zeroes (yr mo day Hour min sec)

// Rtc.SetDateTime(t); //configure the RTC with object // send about 25 secs before actual time.gov time to allow for compile

}

int autowh = 1; // default mode for deicer/water heater is auto mode

void loop() {

ArduinoOTA.handle(); //*** Enables OTA programming. 3 of 3 lines

// mcp.digitalWrite(5, mcp.digitalRead(4)); // Test input button on MCP23017. Mirror inverted state on mcp output 6

//*************Analog Input read******************************************************

analoginput = analogRead(0); //Check!! Nodemcu 12E is digital 0 to 1024 for input 0 to 3.3V NOT 0 to 1.0V on pin A0.

furnaceONvalue = analoginput; // furnace program uses this variable for analog input of furnace LED ON

//*******Get Date and Time*************************************************

RtcDateTime t = Rtc.GetDateTime(); //get the time from the RTC

char str[15]; //declare a string as an array of chars

sprintf(str, "%d/%d/%d %d:%d:%d", //%d allows to print an integer to the string

t.Year(), //get year method

t.Month(), //get month method

t.Day(), //get day method

t.Hour(), //get Hour method

t.Minute(), //get Minute method

t.Second() //get Second method

);

//********End Get Date and Time***********************************************

//*********Wellpump ON/OFF Logic*************************************************

// Turn ON Wellpump when SYS ON is high, Barrel is not full, Wellpump is off, water is detected and offtime > value

if(Barrel_level >= 100) Barrel_full = 1; // Set Barrel_full bit if level is 100%

if(Barrel_level <= 98) Barrel_full = 0; // Reset Barrel_full bit if below 98%

if((yvalue == HIGH) && (Barrel_full == 0) && (WellpumpON == 0) && (wellwater >= 250) && (furnaceOFFtime > 120)) WellpumpON = 1;

if(welltimer >= 10) WellpumpON = 0;

if(WellpumpON == 0) welltimer = 0;

// Auto ON from web page sets autowh = 1. Auto OFF always turns Wellpump ON. Default is ON

if(WellpumpON == 1) digitalWrite(D6, LOW);// Wellpump is on NC contacts so Default is OFF. LOW activates relay to turn Wellpump ON

if(WellpumpON == 0) digitalWrite(D6, HIGH);// LOW deactivates relay to turn Wellpump ON

//********End Wellpump ON/OFF Logic*********************************************

//*********Tankpump ON/OFF Logic*************************************************

if ((yvalue == 1) && ((rvalue == 1) && (Tank_level < 15))) TankpumpON = 1; // yvalue = Sys ON bit rvalue = Tank fill bit

if (TankpumpON == 1) { digitalWrite(D7, LOW); // Turn ON tank pump

}

// TOILET TANK FILL TIME

if ((filltime > 1050) || (rvalue == 0) || (yvalue == 0)) TankpumpON = 0;

if (TankpumpON == 0) { digitalWrite(D7, HIGH); // Turn OFF tank pump

filltime = 0;

}

//*********Tankpump ON/OFF Logic*************************************************

//********Old Water Heat ON logic for day of week and time operations for reference - deactivated

/*

if((t.DayOfWeek() >= 1) && (t.DayOfWeek() <=5)){ //check if it's a weekday

wkday = 1;

}

else {

wkday = 0;

}

if(((t.Hour() == 5) && (t.Minute() >= 50)) //check if between 5:50 and 23:50

|| (t.Hour() >= 6) && (t.Hour() < 23)

|| ((t.Hour() == 23) && (t.Minute() <= 50))){

offtimewh = 1;

}

else {

offtimewh = 0;

}

if ((wkday == 1) && (offtimewh == 1) && (autowh == 1)){ //if weekday and offtime and auto mode turn off water heater

digitalWrite(D4, HIGH); // Wellpump is on NC relay contacts so Default is ON. HIGH activates relay to turn Wellpump OFF

WellpumpOFF = 1;

}

else {

digitalWrite(D4, LOW); // Wellpump is on NC relay contacts so Default is ON. LOW deactivates relay to turn Wellpump ON

WellpumpOFF = 0;

}

*/

//*********End Water Heater Logic****************************************************

//********Read temp and humidity from DHT22 and DS18B20s*****************************

sensors.requestTemperatures(); // Send the command to get temperatures from DS18B20s

// Reading temperature or humidity takes about 250 milliSeconds!

// Sensor readings may also be up to 2 Seconds 'old' (its a very slow sensor)

// float h1 = dht1.readHumidity(); //DHT1 humidity

// delay(50);

// float t1 = dht1.readTemperature(); //DHT1 temp

// delay(50);

// if ((h1 > 100) || (t1 > 40)) {// Read error checking. If error set to previous reading.

// h1 = prevh1; // Was returning double values sometimes.

// t1 = prevt1;

// }

// prevh1=h1;

// prevt1=t1;

// Check if any reads failed and exit early (to try again).

// if (isnan(h1) || isnan(t1)) {

// Serial.println("Failed to read from DHT sensor!");

// return;

// }

temp1raw = sensors.getTempCByIndex(0); //DSB1820 temp1

if ((temp1raw > -50.0) && (temp1raw < 50.0)) temp1 = temp1raw; // error checking

temp2raw = sensors.getTempCByIndex(1); //DSB1820 temp2

if ((temp2raw > -50.0) && (temp2raw < 50.0)) temp2 = temp2raw; // error checking

//********End read temp and humidity****************************************

//*****Read Ultrasonics*********************************************************

if ((t.Second() == 0) || (t.Second() == 10) || (t.Second() == 20) || (t.Second() == 30) || (t.Second() == 40) || (t.Second() == 50)) ultrasonics_read = 0; // reset ultrasonics_read bit after 0

if (ultrasonics_read == 0){ // only read ultrasonics for one second every 10 seconds

ultrasonics_read = 1; // only read once every ten seconds

// Barrel Sensor

delay(10);

// Clears the trig

digitalWrite(trig, LOW);

delayMicroseconds(2);

// Sets the trigPin on HIGH state for 10 micro seconds

digitalWrite(trig, HIGH);

delayMicroseconds(10);

digitalWrite(trig, LOW);

// Reads the echoPin, returns the sound wave travel time in microseconds

Barrelduration = pulseIn(Barrelecho, HIGH);

// Calculating the distance

Barreldistance = Barrelduration*0.17;

if (Barreldistance > 10 ) Barrel_level = 100*(835-Barreldistance)/805; // Barrel_level in % of 805mm

delay(100);

// Tank Sensor

delay(10);

// Clears the trig

digitalWrite(trig, LOW);

delayMicroseconds(2);

// Sets the trigPin on HIGH state for 10 micro seconds

digitalWrite(trig, HIGH);

delayMicroseconds(10);

digitalWrite(trig, LOW);

// Reads the echoPin, returns the sound wave travel time in microseconds

Tankduration = pulseIn(Tankecho, HIGH);

// Calculating the distance

Tankdistance = Tankduration*0.17;

if (Tankdistance > 10 ) Tank_level = 100*(208-Tankdistance)/154; // Tank level in % of 154 mm

delay(10);

}//

//*****End Read Ultrasonics*****************************************************

//***read water present at wellsensor *****

wellwater = 1024 - analogRead(0);

//********end calculate amps*******************

//*****Run following every second***********************************************

//********Wellpump Recording Logic**********************************************

// Wellpump record ON and OFF times. Default is Wellpump OFF so WellpumpOFF=0 means Wellpump is ON

if(lastSecond != t.Second()) {

lastSecond = t.Second();

if((WellpumpON == 1) && (furnaceONtime < 99999)) {furnaceONtime = furnaceONtime +1;}

if(WellpumpON == 1) {ONtotal = ONtotal +1;}

if(WellpumpON == 1) welltimer = welltimer +1;

if((WellpumpON == 0) && (furnaceOFFtime < 99999)) {furnaceOFFtime = furnaceOFFtime +1;}

}

if(TankpumpON == 1) filltime = filltime +1; //If tank pump ON increment fill timer

if(furnaceONtime == 2) {furnaceOFFrecord = furnaceOFFtime;}

if(furnaceONtime == 3) {furnaceOFFtime = 0;}

if((furnaceOFFtime == 2) && (furnaceONtime > 120)) {furnaceONrecord = furnaceONtime;}

if(furnaceOFFtime == 3) {furnaceONtime = 0;}

if (furnaceONrecord > 10) ONpercent = 100 * furnaceONrecord / (furnaceONrecord + furnaceOFFrecord);

//reset ONpercent if furnace off for 3600 secs or 1 Hour

if (furnaceOFFtime >= 3600){

ONpercent = 0;}

// zero counter at top of hour

if ((t.Minute() > 55) ) recordbit = 1; //actions set to a second are unreliable set recordbit at 55 mins+

// Record ONpercent every Hour

if ((recordbit == 1) && (t.Hour() == 0) && (t.Minute() == 0) ){ //record at earliest time in first minute

recordbit = 0;

ONtotal0 = ONtotal;

ONhour0 = ONtotal - ONtotal23;

Kwhtotal = ONtotal0/3600.0; // Convert total ON seconds for previous day to Kwh

ONtotal = 0; // reset ONtotal to zero at midnight after recording total for previous day

ONpct0 = Barrel_level;}

if ((recordbit == 1) && (t.Hour() == 1) && (t.Minute() == 0) ){

recordbit = 0;

ONtotal1 = ONtotal;

ONhour1 = ONtotal;

ONpct1 = Barrel_level;}

if ((recordbit == 1) && (t.Hour() == 2) && (t.Minute() == 0) ){

recordbit = 0;

ONtotal2 = ONtotal;

ONhour2 = ONtotal - ONtotal1;

ONpct2 = Barrel_level;}

if ((recordbit == 1) && (t.Hour() == 3) && (t.Minute() == 0) ){

recordbit = 0;

ONtotal3 = ONtotal;

ONhour3 = ONtotal - ONtotal2;

ONpct3 = Barrel_level;}

if ((recordbit == 1) && (t.Hour() == 4) && (t.Minute() == 0) ){

recordbit = 0;

ONtotal4 = ONtotal;

ONhour4 = ONtotal - ONtotal3;

ONpct4 = Barrel_level;}

if ((recordbit == 1) && (t.Hour() == 5) && (t.Minute() == 0) ){

recordbit = 0;

ONtotal5 = ONtotal;

ONhour5 = ONtotal - ONtotal4;

ONpct5 = Barrel_level;}

if ((recordbit == 1) && (t.Hour() == 6) && (t.Minute() == 0) ){

recordbit = 0;

ONtotal6 = ONtotal;

ONhour6 = ONtotal - ONtotal5;

ONpct6 = Barrel_level;}

if ((recordbit == 1) && (t.Hour() == 7) && (t.Minute() == 0) ){

recordbit = 0;

ONtotal7 = ONtotal;

ONhour7 = ONtotal - ONtotal6;

ONpct7 = Barrel_level;}

if ((recordbit == 1) && (t.Hour() == 8) && (t.Minute() == 0) ){

recordbit = 0;

ONtotal8 = ONtotal;

ONhour8 = ONtotal - ONtotal7;

ONpct8 = Barrel_level;}

if ((recordbit == 1) && (t.Hour() == 9) && (t.Minute() == 0) ){

recordbit = 0;

ONtotal9 = ONtotal;

ONhour9 = ONtotal - ONtotal8;

ONpct9 = Barrel_level;}

if ((recordbit == 1) && (t.Hour() == 10) && (t.Minute() == 0) ){

recordbit = 0;

ONtotal10 = ONtotal;

ONhour10 = ONtotal - ONtotal9;

ONpct10 = Barrel_level;}

if ((recordbit == 1) && (t.Hour() == 11) && (t.Minute() == 0)){

recordbit = 0;

ONtotal11 = ONtotal;

ONhour11 = ONtotal - ONtotal10;

ONpct11 = Barrel_level;}

if ((recordbit == 1) && (t.Hour() == 12) && (t.Minute() == 0) ){

recordbit = 0;

ONtotal12 = ONtotal;

ONhour12 = ONtotal - ONtotal11;

ONpct12 = Barrel_level;}

if ((recordbit == 1) && (t.Hour() == 13) && (t.Minute() == 0) ){

recordbit = 0;

ONtotal13 = ONtotal;

ONhour13 = ONtotal - ONtotal12;

ONpct13 = Barrel_level;}

if ((recordbit == 1) && (t.Hour() == 14) && (t.Minute() == 0) ){

recordbit = 0;

ONtotal14 = ONtotal;

ONhour14 = ONtotal - ONtotal13;

ONpct14 = Barrel_level;}

if ((recordbit == 1) && (t.Hour() == 15) && (t.Minute() == 0) ){

recordbit = 0;

ONtotal15 = ONtotal;

ONhour15 = ONtotal - ONtotal14;

ONpct15 = Barrel_level;}

if ((recordbit == 1) && (t.Hour() == 16) && (t.Minute() == 0) ){

recordbit = 0;

ONtotal16 = ONtotal;

ONhour16 = ONtotal - ONtotal15;

ONpct16 = Barrel_level;}

if ((recordbit == 1) && (t.Hour() == 17) && (t.Minute() == 0) ){

recordbit = 0;

ONtotal17 = ONtotal;

ONhour17 = ONtotal - ONtotal16;

ONpct17 = Barrel_level;}

if ((recordbit == 1) && (t.Hour() == 18) && (t.Minute() == 0) ){

recordbit = 0;

ONtotal18 = ONtotal;

ONhour18 = ONtotal - ONtotal17;

ONpct18 = Barrel_level;}

if ((recordbit == 1) && (t.Hour() == 19) && (t.Minute() == 0) ){

recordbit = 0;

ONtotal19 = ONtotal;

ONhour19 = ONtotal - ONtotal18;

ONpct19 = Barrel_level;}

if ((recordbit == 1) && (t.Hour() == 20) && (t.Minute() == 0)){

recordbit = 0;

ONtotal20 = ONtotal;

ONhour20 = ONtotal - ONtotal19;

ONpct20 = Barrel_level;}

if ((recordbit == 1) && (t.Hour() == 21) && (t.Minute() == 0) ){

recordbit = 0;

ONtotal21 = ONtotal;

ONhour21 = ONtotal - ONtotal20;

ONpct21 = Barrel_level;}

if ((recordbit == 1) && (t.Hour() == 22) && (t.Minute() == 0) ){

recordbit = 0;

ONtotal22 = ONtotal;

ONhour22 = ONtotal - ONtotal21;

ONpct22 = Barrel_level;}

if ((recordbit == 1) && (t.Hour() == 23) && (t.Minute() == 0) ){

recordbit = 0;

ONtotal23 = ONtotal;

ONhour23 = ONtotal - ONtotal22;

ONpct23 = Barrel_level;}

//reset ONpercent if furnace off for 3600 secs or 1 Hour

if (furnaceOFFtime >= 3600){

ONpercent = 0;}

//********End Furnace Logic*****************************************************

//********Send Wellpump_Fail Text Alert*******************************************************

// Extra data to send can send up to 3 values

/*

String v1_f = String(Kwhtotal);

String v2_f = String(temp1,1);

String v3_f = String(amps,1);

// Convert float value to a string named sv3

//char sv3[16];

//dtostrf(v3,8, 2, sv3);

String df1_f = "{\"value1\":";

String df2_f = "\"value2\":";

String df3_f = "\"value3\":";

// Create body data string

String IFTTT_POST_DATA_fail = df1_f + "\"" + v1_f + "\"" + "," + df2_f + "\"" + v2_f + "\"" + "," + df3_f + "\"" + v3_f + "\"" + "}" ;

// Determine body data string size

String IFTTT_POST_DATA_SIZE_fail = String(IFTTT_POST_DATA_fail.length());

// Send HTTP POST Request to IFTTT

if(t.Minute() == 59) {// reset hourly alert at 59 minutes

alertreset = 1;

}

else {

alertreset = 0;

}

if (

((alertreset == 0) && (alertsent_fail == 0)) //Alert reset every hour and alert sent only once for true

&&

(WellpumpOFF == 0) //Wellpump should be ON. Will be on Auto OFF

&&

(furnaceONtime > 5) //Wellpump powered on for 5 secs to allow startup current

&&

((amps < 4.0) || (amps > 12.0)) //Current less than 4 amps or more than 12 amps

)

{

WiFiClient client;

const int httpPort = 80;

client.connect(host, httpPort);

client.print(String("POST ") + urlfail + " HTTP/1.1\r\n"

+ "Host: " + host + "\r\n"

+ "Connection: close\r\n"

+ "Content-Type: application/json\r\n"

+ "Content-Length: " + IFTTT_POST_DATA_SIZE_fail + "\r\n"

+ "\r\n"

+ IFTTT_POST_DATA_fail + "\r\n");

alertsent_fail=1; // alertsent_fail bit set so only sends once

}

if ((alertreset == 1) || (WellpumpOFF ==1)) alertsent_fail = 0; // reset send fail alert every hour or WellpumpOFF

*/

//********End Wellpump_Fail Send Text Alert************************************************

//********Send Wellpump_Data Text Alert*******************************************************

// Extra data to send can send up to 3 values

/*

String v1_d = String(Kwhtotal);

String v2_d = String(temp1,1);

String v3_d = String(amps,1);

// Convert float value to a string named sv3

//char sv3[16];

//dtostrf(v3,8, 2, sv3);

String df1_d = "{\"value1\":";

String df2_d = "\"value2\":";

String df3_d = "\"value3\":";

// Create body data string

String IFTTT_POST_DATA_data = df1_d + "\"" + v1_d + "\"" + "," + df2_d + "\"" + v2_d + "\"" + "," + df3_d + "\"" + v3_d + "\"" + "}" ;

// Determine body data string size

String IFTTT_POST_DATA_SIZE_data = String(IFTTT_POST_DATA_data.length());

// Send HTTP POST Request to IFTTT

if ((alertsent_data == 0) && (t.Hour() == 0)&& (t.Minute() < 6) )

{

WiFiClient client;

const int httpPort = 80;

client.connect(host, httpPort);

client.print(String("POST ") + urldata + " HTTP/1.1\r\n"

+ "Host: " + host + "\r\n"

+ "Connection: close\r\n"

+ "Content-Type: application/json\r\n"

+ "Content-Length: " + IFTTT_POST_DATA_SIZE_data + "\r\n"

+ "\r\n"

+ IFTTT_POST_DATA_data + "\r\n");

alertsent_data=1; // alertsent_data bit set so only sends once

}

if (t.Hour() > 0) alertsent_data = 0;

*/

//********End Send Wellpump_Data Text Alert************************************************

//*******WiFi detect client and record input********************************

// Check if a client has connected

WiFiClient client = server.available();

if (!client) {

return;

}

// Read the first line of the request

request = client.readStringUntil('\r');

client.flush();

//*******End of WiFi detect client and record input********************************

//*************Actions on button click. Buttons defined below.************************

if (request.indexOf("/YELLOW_LED=ON") != -1) {// Input from screen. No spaces in name.

yvalue = HIGH;

}

if (request.indexOf("/YELLOW_LED=OFF") != -1) {// Input from screen. No spaces in name.

yvalue = LOW;

}

// Match the request for Red LED Manual Fill Tank bit

if (request.indexOf("/RED_LED=ON") != -1) {// yvalue = Sys ON. Input from screen. No spaces in name.

rvalue = HIGH;

}

if (request.indexOf("/RED_LED=OFF") != -1) {// Input from screen. No spaces in name.

rvalue = LOW;

}

if (request.indexOf("/AUTO_ON") != -1) {// Input from screen. No spaces in name. Water heater auto mode

autowh = 1;

}

if (request.indexOf("/AUTO_OFF") != -1) {// Input from screen. No spaces in name. Water heater auto mode

autowh = 0;

}

request.indexOf("/HOME"); // Go to Home page after LEDs set.

//*******End of button actions******************************************************

//****** Return the response in HTML on web page************************************

client.println("HTTP/1.1 200 OK");

client.println("Content-Type: text/html");

client.println(""); // do not forget this one

client.println("<!DOCTYPE HTML>");

client.println( // start code html with this. Have to add quotes before and after. Delete most html quotes in line.

"<html>"

"<head>"

"<title>Water System</title>"

// "<meta http-equiv=refresh content=60; url=/http://192.168.0.137//>" // Auto refresh every 60 secs. Issues?

"<meta name=viewport content=width=720px, initial-scale=1.0>"

"<meta name=viewport shrink-to-fit=yes>"

"</head>"

"<style> p {font-size: 14px; color:blue; font-family:monospace;} </style>" //Use monospace font to make columns of text and numbers line up

"<p>"); // large font applies between <p> and </p> below

//*********End HTML page start of defintion*****************************************

//*****Background Images** Use background= for all your jpgs. HTML position does not work. Add big white spc in jpg to right and below to stop repeats.

client.println("<body background= https://sites.google.com/site/nodemcuwebpics/home/water_schematic.PNG");

client.println("<background-repeat = no-repeat;>");

client.println("</body>");

//*****End of background images

//*********Print Date and Time add leading zeroes***********************************

Hour = String(t.Hour()); // integers like t.Hour() are used for comparisons and control. Change to string for display and add leading zeroes

if (t.Hour() <= 9) Hour = "0" + Hour; // adjust for 0-9

Minute = String(t.Minute());

if (t.Minute() <= 9) Minute = "0" + Minute; // adjust for 0-9

Second = String(t.Second());

if (t.Second() <= 9) Second = "0" + Second; // adjust for 0-9

if (t.DayOfWeek() == 0) dow = " Sun"; // t.DayOfWeek() calculated from rest of date not from DS3231

if (t.DayOfWeek() == 1) dow = " Mon";

if (t.DayOfWeek() == 2) dow = " Tue";

if (t.DayOfWeek() == 3) dow = " Wed";

if (t.DayOfWeek() == 4) dow = " Thu";

if (t.DayOfWeek() == 5) dow = " Fri";

if (t.DayOfWeek() == 6) dow = " Sat";

Month = String(t.Month());

Day = String(t.Day());

if (t.Month() <= 9) Month = "0" + Month; // adjust for 0-9 in month

if (t.Day() <= 9) Day = "0" + Day; // adjust for 0-9 in day

timedate = String(t.Year())+ "/" + Month + "/" + Day + " " + Hour + ":" + Minute + ":" + Second ; // create string for display with one client.println

client.println(timedate);

client.println("&emsp;"); // add spaces

client.println(dow); // print day of week

client.println("&emsp;"); // add spaces

//*********End Print Date and Time********************************************

//*********Button Style defintion CSS******************************************************************

client.println( //html output. Put quotes around html code. Don't have to client.println every line

"<style>" // button style definition

".button {"

"background-color: #008CBA; /* Blue */"

"border: none;"

"border-radius: 4px;"

"color: yellow;"

"padding: 12px 24px;"

"text-align: center;"

"text-decoration: none;"

"display: inline-block;"

"font-size: 16px;"

"}"

"</style>"

//*****End Button Style Definition************************************************************************************************

//******Buttons Definitions************************************************************************************************

"<br>"

"<a href=\"/YELLOW_LED=ON\"\"><button class=button>SYS ON </button></a>" // Yellow LED ON button definition. No spaces

"&nbsp;" // horizontal space between buttons

"<a href=\"/YELLOW_LED=OFF\"\"><button class=button>SYS OFF </button></a>" //Yellow LED OFF button definition. No spaces

"&emsp;"

"<a href=\"/RED_LED=ON\"\"><button class=button>FILL ON </button></a>" // Red LED ON button definition. No spaces

"&nbsp;" // horizontal space between buttons

"<a href=\"/RED_LED=OFF\"\"><button class=button>FILL OFF </button></a>" //Red LED OFF button definition. No spaces

"&emsp;" // horizontal space between buttons

"<a href=\"/HOME\"\"><button class=button>HOME </button></a>"); //Home button definition. No spaces

// client.print("&emsp; &emsp;"); // add spaces

//client.println(

// "&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;"); // add spaces

//*****End Button Definition************************************************************************************************

//*****send LED status pics*************************************************************************************************

// if (digitalRead(D0) == 0) yvalue = 1;

// if (digitalRead(D0) == 1) yvalue = 0;

// if (digitalRead(D4) == 0) rvalue = 1;

// if (digitalRead(D4) == 1) rvalue = 0;

if ((yvalue == HIGH) && (rvalue == HIGH)){

client.println("<img src= https://sites.google.com/site/nodemcu12e/home/yon%20ron.PNG height=30 width=65;>");

client.println("<br>");

}

if ((yvalue == LOW) && (rvalue == LOW)){

client.println("<img src= https://sites.google.com/site/nodemcu12e/home/yoff%20roff.PNG height=30 width=65;>");

client.println("<br>");

}

if ((yvalue == HIGH) && (rvalue == LOW)){

client.println("<img src= https://sites.google.com/site/nodemcu12e/home/yon%20roff.PNG height=30 width=65;>");

client.println("<br>");

}

if ((yvalue == LOW) && (rvalue == HIGH)){

client.println("<img src= https://sites.google.com/site/nodemcu12e/home/yoff%20ron.PNG height=30 width=65;>");

client.println("&nbsp;");

}

client.println("<br>");

// client.println("<br>");

client.println("<iframe src=http://free.timeanddate.com/clock/i5ry49b9/n4925/tlca/tt0/tw1/tm1/tb4 frameborder=0 width=120 height=34></iframe>"); // internet date and time display

client.println("<style> p {font-size: 14px; color:blue; font-family:monospace;} </style>" //Use monospace font to make columns of text and numbers line up

"<p>"); // large font applies between <p> and </p> below

//*****end LED status pics. No spaces in file names or it adds %20 for space in file name***************************************

//*****send Images to web page. Image files are stored on a Google web site so only link is needed here.*****

// client.println("<br>" // carriage return start new line

// "<br>"

// "<br>"

// "&emsp;&emsp;&emsp;"

client.println("<style> p {font-size: 14px; color:blue; font-family:monospace;} </style>" //Use monospace font to make columns of text and numbers line up

"<p>"); // large font applies between <p> and </p> below

// "<br>");

//client.println("&emsp;&emsp;&emsp;"); // add space

//client.println("Inside Temp");

//client.println(t1,1); // print temp

//client.println("C"); // print temp

//client.println("&nbsp;"); // add space

//client.println("RH"); // print temp

//client.println(h1,1); // print humidity

//client.println("%"); // print humidity %

//client.println("&nbsp;");

//client.println("Furnace LED: ");

//client.println(analoginput);

//client.println("&nbsp;");

//client.println(" Basement Temp ");

//client.println(temp1,1); //One decimal place

//client.println("C");

//client.println("&nbsp;");

//client.println(" Water Temp ");

//client.println(temp2,1); //One decimal place

//client.println("C");

// client.println("&emsp;&emsp;"); // add space

//client.println("Inside Temp");

//insidetemp = String(t1,1)+"C ";

//humidity = "RH "+String(h1,1)+"% ";

//furnaceLED = "Furnace LED "+String(analoginput)+" ";

//basementtemp = "Basement Temp "+String(temp1,1)+"C ";

outsidetemp = "Water "+String(temp1,1)+"C";

tempdata = outsidetemp;

client.println(tempdata);

client.println("&emsp;");

// ONtempstring = "ON Temp "+String(ONtemp,1)+"C";

// client.println(ONtempstring);client.println("&emsp;");

client.println(" Well ");

client.println(wellwater);

client.println("&emsp;");

barrel = "Barrel "+String(Barrel_level)+"%";

if (Barrel_level == 99) barrel = "Barrel " + String("100") + "%";

if (Barrel_level == 101) barrel = "Barrel " + String("100") + "%";

client.println(barrel);

client.println("&emsp;");

tank = "Tank "+String(Tank_level)+"%";

if (Tank_level < 3) tank = "Tank "+ String(" 0")+"%";

if ((Tank_level >= 98) && (Tank_level <= 102)) tank = "Tank "+ String("100")+"%";

client.println(tank);

client.println("&emsp;");

client.println(" Fill ");

client.println(filltime);

client.println("<br>");

client.println("<br>");

client.println("&emsp;&emsp;&emsp;&emsp;");

//******Show blue propeller rotating if amps >= 1.0 othewise stopped*********

/* if (amps >= 100.0){// show impeller GIF rotating

client.println("<iframe src=http://www.fusionfluid.com/FusionFluidEquipmentLLC/images/Impeller%20-%20Square%20Pitch%20Marine%20Prop%20-%20Spinning%20-%20450px.gif width=450 height=338 frameBorder=0 class=giphy-embed allowFullScreen></iframe><p><a href=https://giphy.com/gifs/marine-8VuewjJUbAsCc></a></p>");

client.println("<style> p {font-size: 14px; color:blue; font-family:monospace;} </style>" //Use monospace font to make columns of text and numbers line up

"<p>"); // large font applies between <p> and </p> below

// client.println("<br>");

}

if (amps < 100.0){// show impeller stopped

client.println("<img src=https://sites.google.com/site/nodemcu12e/home/water_schematic.PNG?attredirects=0 >");

client.println("<style> p {font-size: 14px; color:blue; font-family:monospace;} </style>" //Use monospace font to make columns of text and numbers line up

"<p>"); // large font applies between <p> and </p> below

//client.println("<br>");

}

*/

//**********************************************************

// client.println("&emsp;");

//client.println("&emsp;");

client.println(

//***Furnace and water heater buttons***************

"&emsp;" //Clear Flag button definition. No spaces

"&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp; <a href=\"/AUTO_ON\"\"><button class=button>AUTO ON</button></a>"

"&nbsp;<a href=\"/AUTO_OFF\"\"><button class=button>AUTO OFF</button></a>");

//***End furnace and water heater buttons***********

// "<br>");

//****Print furnace and water heater data

client.println("<style> p {font-size: 14px; color:blue; font-family:monospace;} </style>" //Use monospace font to make columns of text and numbers line up

"<p>"); // large font applies between <p> and </p> below

// client.println("&emsp;");

// client.println("&emsp;&emsp;&emsp;");

//if (furnaceONvalue > 100) { client.println("Furnace:ON "); client.println("&nbsp");}

//if (furnaceONvalue < 50) client.println("Furnace:OFF");

client.println("&nbsp");

// if (furnacelo == 1) client.println("LO");

// if (furnacelo == 0) client.println("HI");

// client.println("&emsp;");

// client.println("Low SP");

//client.println(lowsetpoint,1);

client.println("&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;");

if (autowh == 1) client.println("Auto:ON ");

if (autowh == 0) client.println("Auto:OFF");

client.println("&emsp;");

client.println("Barrel Full");

client.println(Barrel_full);

client.println("&emsp;");

if (WellpumpON == 0) client.println("Wellpump:OFF");

if (WellpumpON == 1) client.println("Wellpump:ON");

client.println("&emsp;");

if (TankpumpON == 0) client.println("Tankpump:OFF");

if (TankpumpON == 1) client.println("Tankpump:ON");

client.println("<br>");

client.println("<br>");

client.println("&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;");

client.println("ON time");

StrfurnaceONtime = "&nbsp" + String(furnaceONtime);

if (furnaceONtime < 10) StrfurnaceONtime = "&nbsp" + StrfurnaceONtime; // add leading spaces

if (furnaceONtime < 100) StrfurnaceONtime = "&nbsp" + StrfurnaceONtime;

if (furnaceONtime < 1000) StrfurnaceONtime = "&nbsp" + StrfurnaceONtime;

if (furnaceONtime < 10000) StrfurnaceONtime = "&nbsp" + StrfurnaceONtime;

client.println(StrfurnaceONtime);

client.println("Rcrd");

StrfurnaceONrecord = String(furnaceONrecord);

if (furnaceONrecord < 10) StrfurnaceONrecord = "&nbsp" + StrfurnaceONrecord; // add leading spaces

if (furnaceONrecord < 100) StrfurnaceONrecord = "&nbsp" + StrfurnaceONrecord;

if (furnaceONrecord < 1000) StrfurnaceONrecord = "&nbsp" + StrfurnaceONrecord;

if (furnaceONrecord < 10000) StrfurnaceONrecord = "&nbsp" + StrfurnaceONrecord;

client.println(StrfurnaceONrecord);

client.println("<br>");

client.println("&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;");

client.println("OFF time");

StrfurnaceOFFtime = String(furnaceOFFtime);

if (furnaceOFFtime < 10) StrfurnaceOFFtime = "&nbsp" + StrfurnaceOFFtime; // add leading spaces

if (furnaceOFFtime < 100) StrfurnaceOFFtime = "&nbsp" + StrfurnaceOFFtime;

if (furnaceOFFtime < 1000) StrfurnaceOFFtime = "&nbsp" + StrfurnaceOFFtime;

if (furnaceOFFtime < 10000) StrfurnaceOFFtime = "&nbsp" + StrfurnaceOFFtime;

client.println(StrfurnaceOFFtime);

client.println("Rcrd");

StrfurnaceOFFrecord = String(furnaceOFFrecord);

if (furnaceOFFrecord < 10) StrfurnaceOFFrecord = "&nbsp" + StrfurnaceOFFrecord; // add leading spaces

if (furnaceOFFrecord < 100) StrfurnaceOFFrecord = "&nbsp" + StrfurnaceOFFrecord;

if (furnaceOFFrecord < 1000) StrfurnaceOFFrecord = "&nbsp" + StrfurnaceOFFrecord;

if (furnaceOFFrecord < 10000) StrfurnaceOFFrecord = "&nbsp" + StrfurnaceOFFrecord;

client.println(StrfurnaceOFFrecord);

client.println("<br>");

client.println("&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;");

client.println("ON total");

StrONtotal = String(ONtotal);

if (ONtotal < 10) StrONtotal = "&nbsp" + StrONtotal; // add leading spaces

if (ONtotal < 100) StrONtotal = "&nbsp" + StrONtotal;

if (ONtotal < 1000) StrONtotal = "&nbsp" + StrONtotal;

if (ONtotal < 10000) StrONtotal = "&nbsp" + StrONtotal;

client.println(StrONtotal);

client.println("ON%");

client.println(ONpercent);

client.println("<br>");

client.println("&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;");

String heading = "Tm Total Hour";

heading = heading + "&nbsp" + "&nbsp"+ "&nbsp";

heading = heading + "%" + "&nbsp"+ " "; // was KWHtotal in spc

client.println(heading);

client.println("<br>");

client.println("&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;");

String StrONtotal0 = String(ONtotal0);

if (ONtotal0 < 10) StrONtotal0 = "&nbsp" + StrONtotal0; // add leading spaces

if (ONtotal0 < 100) StrONtotal0 = "&nbsp" + StrONtotal0;

if (ONtotal0 < 1000) StrONtotal0 = "&nbsp" + StrONtotal0;

if (ONtotal0 < 10000) StrONtotal0 = "&nbsp" + StrONtotal0;

String StrONhour0 = String(ONhour0);

if (ONhour0 < 10) StrONhour0 = "&nbsp" + StrONhour0; // add leading spaces

if (ONhour0 < 100) StrONhour0 = "&nbsp" + StrONhour0;

if (ONhour0 < 1000) StrONhour0 = "&nbsp" + StrONhour0;

String StrONpct0 = String(ONpct0);

if (ONpct0 < 10) StrONpct0 = "&nbsp" + StrONpct0; // add leading spaces

if (ONpct0 < 100) StrONpct0 = "&nbsp" + StrONpct0; // add leading spaces

client.println("00");

client.println(StrONtotal0);

client.println(StrONhour0);

client.println(StrONpct0);

String StrKwhtotal = String(Kwhtotal,1);

client.println("&emsp;");

// client.println(StrKwhtotal);

client.println("<br>");

client.println("&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;");

String StrONtotal1 = String(ONtotal1);

if (ONtotal1 < 10) StrONtotal1 = "&nbsp" + StrONtotal1; // add leading spaces

if (ONtotal1 < 100) StrONtotal1 = "&nbsp" + StrONtotal1;

if (ONtotal1 < 1000) StrONtotal1 = "&nbsp" + StrONtotal1;

if (ONtotal1 < 10000) StrONtotal1 = "&nbsp" + StrONtotal1;

String StrONhour1 = String(ONhour1);

if (ONhour1 < 10) StrONhour1 = "&nbsp" + StrONhour1; // add leading spaces

if (ONhour1 < 100) StrONhour1 = "&nbsp" + StrONhour1;

if (ONhour1 < 1000) StrONhour1 = "&nbsp" + StrONhour1;

String StrONpct1 = String(ONpct1);

if (ONpct1 < 10) StrONpct1 = "&nbsp" + StrONpct1; // add leading spaces

if (ONpct1 < 100) StrONpct1 = "&nbsp" + StrONpct1; // add leading spaces

client.println("01");

client.println(StrONtotal1);

client.println(StrONhour1);

client.println(StrONpct1);

client.println("<br>");

client.println("&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;");

String StrONtotal2 = String(ONtotal2);

if (ONtotal2 < 10) StrONtotal2 = "&nbsp" + StrONtotal2; // add leading spaces

if (ONtotal2 < 100) StrONtotal2 = "&nbsp" + StrONtotal2;

if (ONtotal2 < 1000) StrONtotal2 = "&nbsp" + StrONtotal2;

if (ONtotal2 < 10000) StrONtotal2 = "&nbsp" + StrONtotal2;

String StrONhour2 = String(ONhour2);

if (ONhour2 < 10) StrONhour2 = "&nbsp" + StrONhour2; // add leading spaces

if (ONhour2 < 100) StrONhour2 = "&nbsp" + StrONhour2;

if (ONhour2 < 1000) StrONhour2 = "&nbsp" + StrONhour2;

String StrONpct2 = String(ONpct2);

if (ONpct2 < 10) StrONpct2 = "&nbsp" + StrONpct2; // add leading spaces

if (ONpct2 < 100) StrONpct2 = "&nbsp" + StrONpct2; // add leading spaces

client.println("02");

client.println(StrONtotal2);

client.println(StrONhour2);

client.println(StrONpct2);

client.println("<br>");

client.println("&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;");

String StrONtotal3 = String(ONtotal3);

if (ONtotal3 < 10) StrONtotal3 = "&nbsp" + StrONtotal3; // add leading spaces

if (ONtotal3 < 100) StrONtotal3 = "&nbsp" + StrONtotal3;

if (ONtotal3 < 1000) StrONtotal3 = "&nbsp" + StrONtotal3;

if (ONtotal3 < 10000) StrONtotal3 = "&nbsp" + StrONtotal3;

String StrONhour3 = String(ONhour3);

if (ONhour3 < 10) StrONhour3 = "&nbsp" + StrONhour3; // add leading spaces

if (ONhour3 < 100) StrONhour3 = "&nbsp" + StrONhour3;

if (ONhour3 < 1000) StrONhour3 = "&nbsp" + StrONhour3;

String StrONpct3 = String(ONpct3);

if (ONpct3 < 10) StrONpct3 = "&nbsp" + StrONpct3; // add leading spaces

if (ONpct3 < 100) StrONpct3 = "&nbsp" + StrONpct3; // add leading spaces

client.println("03");

client.println(StrONtotal3);

client.println(StrONhour3);

client.println(StrONpct3);

client.println("&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;");

client.println("&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;");

client.println(tank);

client.println("<br>");

client.println("&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;");

String StrONtotal4 = String(ONtotal4);

if (ONtotal4 < 10) StrONtotal4 = "&nbsp" + StrONtotal4; // add leading spaces

if (ONtotal4 < 100) StrONtotal4 = "&nbsp" + StrONtotal4;

if (ONtotal4 < 1000) StrONtotal4 = "&nbsp" + StrONtotal4;

if (ONtotal4 < 10000) StrONtotal4 = "&nbsp" + StrONtotal4;

String StrONhour4 = String(ONhour4);

if (ONhour4 < 10) StrONhour4 = "&nbsp" + StrONhour4; // add leading spaces

if (ONhour4 < 100) StrONhour4 = "&nbsp" + StrONhour4;

if (ONhour4 < 1000) StrONhour4 = "&nbsp" + StrONhour4;

String StrONpct4 = String(ONpct4);

if (ONpct4 < 10) StrONpct4 = "&nbsp" + StrONpct4; // add leading spaces

if (ONpct4 < 100) StrONpct4 = "&nbsp" + StrONpct4; // add leading spaces

client.println("04");

client.println(StrONtotal4);

client.println(StrONhour4);

client.println(StrONpct4);

client.println("&emsp;");

client.println(barrel);

client.println("<br>");

client.println("&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;");

String StrONtotal5 = String(ONtotal5);

if (ONtotal5 < 10) StrONtotal5 = "&nbsp" + StrONtotal5; // add leading spaces

if (ONtotal5 < 100) StrONtotal5 = "&nbsp" + StrONtotal5;

if (ONtotal5 < 1000) StrONtotal5 = "&nbsp" + StrONtotal5;

if (ONtotal5 < 10000) StrONtotal5 = "&nbsp" + StrONtotal5;

String StrONhour5 = String(ONhour5);

if (ONhour5 < 10) StrONhour5 = "&nbsp" + StrONhour5; // add leading spaces

if (ONhour5 < 100) StrONhour5 = "&nbsp" + StrONhour5;

if (ONhour5 < 1000) StrONhour5 = "&nbsp" + StrONhour5;

String StrONpct5 = String(ONpct5);

if (ONpct5 < 10) StrONpct5 = "&nbsp" + StrONpct5; // add leading spaces

if (ONpct5 < 100) StrONpct5 = "&nbsp" + StrONpct5; // add leading spaces

client.println("05");

client.println(StrONtotal5);

client.println(StrONhour5);

client.println(StrONpct5);

client.println("<br>");

client.println("&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;");

String StrONtotal6 = String(ONtotal6);

if (ONtotal6 < 10) StrONtotal6 = "&nbsp" + StrONtotal6; // add leading spaces

if (ONtotal6 < 100) StrONtotal6 = "&nbsp" + StrONtotal6;

if (ONtotal6 < 1000) StrONtotal6 = "&nbsp" + StrONtotal6;

if (ONtotal6 < 10000) StrONtotal6 = "&nbsp" + StrONtotal6;

String StrONhour6 = String(ONhour6);

if (ONhour6 < 10) StrONhour6 = "&nbsp" + StrONhour6; // add leading spaces

if (ONhour6 < 100) StrONhour6 = "&nbsp" + StrONhour6;

if (ONhour6 < 1000) StrONhour6 = "&nbsp" + StrONhour6;

String StrONpct6 = String(ONpct6);

if (ONpct6 < 10) StrONpct6 = "&nbsp" + StrONpct6; // add leading spaces

if (ONpct6 < 100) StrONpct6 = "&nbsp" + StrONpct6; // add leading spaces

client.println("06");

client.println(StrONtotal6);

client.println(StrONhour6);

client.println(StrONpct6);

client.println("<br>");

client.println("&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;");

String StrONtotal7 = String(ONtotal7);

if (ONtotal7 < 10) StrONtotal7 = "&nbsp" + StrONtotal7; // add leading spaces

if (ONtotal7 < 100) StrONtotal7 = "&nbsp" + StrONtotal7;

if (ONtotal7 < 1000) StrONtotal7 = "&nbsp" + StrONtotal7;

if (ONtotal7 < 10000) StrONtotal7 = "&nbsp" + StrONtotal7;

String StrONhour7 = String(ONhour7);

if (ONhour7 < 10) StrONhour7 = "&nbsp" + StrONhour7; // add leading spaces

if (ONhour7 < 100) StrONhour7 = "&nbsp" + StrONhour7;

if (ONhour7 < 1000) StrONhour7 = "&nbsp" + StrONhour7;

String StrONpct7 = String(ONpct7);

if (ONpct7 < 10) StrONpct7 = "&nbsp" + StrONpct7; // add leading spaces

if (ONpct7 < 100) StrONpct7 = "&nbsp" + StrONpct7; // add leading spaces

client.println("07");

client.println(StrONtotal7);

client.println(StrONhour7);

client.println(StrONpct7);

client.println("<br>");

client.println("&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;");

String StrONtotal8 = String(ONtotal8);

if (ONtotal8 < 10) StrONtotal8 = "&nbsp" + StrONtotal8; // add leading spaces

if (ONtotal8 < 100) StrONtotal8 = "&nbsp" + StrONtotal8;

if (ONtotal8 < 1000) StrONtotal8 = "&nbsp" + StrONtotal8;

if (ONtotal8 < 10000) StrONtotal8 = "&nbsp" + StrONtotal8;

String StrONhour8 = String(ONhour8);

if (ONhour8 < 10) StrONhour8 = "&nbsp" + StrONhour8; // add leading spaces

if (ONhour8 < 100) StrONhour8 = "&nbsp" + StrONhour8;

if (ONhour8 < 1000) StrONhour8 = "&nbsp" + StrONhour8;

String StrONpct8 = String(ONpct8);

if (ONpct8 < 10) StrONpct8 = "&nbsp" + StrONpct8; // add leading spaces

if (ONpct8 < 100) StrONpct8 = "&nbsp" + StrONpct8; // add leading spaces

client.println("08");

client.println(StrONtotal8);

client.println(StrONhour8);

client.println(StrONpct8);

client.println("<br>");

client.println("&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;");

String StrONtotal9 = String(ONtotal9);

if (ONtotal9 < 10) StrONtotal9 = "&nbsp" + StrONtotal9; // add leading spaces

if (ONtotal9 < 100) StrONtotal9 = "&nbsp" + StrONtotal9;

if (ONtotal9 < 1000) StrONtotal9 = "&nbsp" + StrONtotal9;

if (ONtotal9 < 10000) StrONtotal9 = "&nbsp" + StrONtotal9;

String StrONhour9 = String(ONhour9);

if (ONhour9 < 10) StrONhour9 = "&nbsp" + StrONhour9; // add leading spaces

if (ONhour9 < 100) StrONhour9 = "&nbsp" + StrONhour9;

if (ONhour9 < 1000) StrONhour9 = "&nbsp" + StrONhour9;

String StrONpct9 = String(ONpct9);

if (ONpct9 < 10) StrONpct9 = "&nbsp" + StrONpct9; // add leading spaces

if (ONpct9 < 100) StrONpct9 = "&nbsp" + StrONpct9; // add leading spaces

client.println("09");

client.println(StrONtotal9);

client.println(StrONhour9);

client.println(StrONpct9);

client.println("<br>");

client.println("&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;");

String StrONtotal10 = String(ONtotal10);

if (ONtotal10 < 10) StrONtotal10 = "&nbsp" + StrONtotal10; // add leading spaces

if (ONtotal10 < 100) StrONtotal10 = "&nbsp" + StrONtotal10;

if (ONtotal10 < 1000) StrONtotal10 = "&nbsp" + StrONtotal10;

if (ONtotal10 < 10000) StrONtotal10 = "&nbsp" + StrONtotal10;

String StrONhour10 = String(ONhour10);

if (ONhour10 < 10) StrONhour10 = "&nbsp" + StrONhour10; // add leading spaces

if (ONhour10 < 100) StrONhour10 = "&nbsp" + StrONhour10;

if (ONhour10 < 1000) StrONhour10 = "&nbsp" + StrONhour10;

String StrONpct10 = String(ONpct10);

if (ONpct10 < 10) StrONpct10 = "&nbsp" + StrONpct10; // add leading spaces

if (ONpct10 < 100) StrONpct10 = "&nbsp" + StrONpct10; // add leading spaces

client.println("10");

client.println(StrONtotal10);

client.println(StrONhour10);

client.println(StrONpct10);

client.println("<br>");

client.println("&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;");

String StrONtotal11 = String(ONtotal11);

if (ONtotal11 < 10) StrONtotal11 = "&nbsp" + StrONtotal11; // add leading spaces

if (ONtotal11 < 100) StrONtotal11 = "&nbsp" + StrONtotal11;

if (ONtotal11 < 1000) StrONtotal11 = "&nbsp" + StrONtotal11;

if (ONtotal11 < 10000) StrONtotal11 = "&nbsp" + StrONtotal11;

String StrONhour11 = String(ONhour11);

if (ONhour11 < 10) StrONhour11 = "&nbsp" + StrONhour11; // add leading spaces

if (ONhour11 < 100) StrONhour11 = "&nbsp" + StrONhour11;

if (ONhour11 < 1000) StrONhour11 = "&nbsp" + StrONhour11;

String StrONpct11 = String(ONpct11);

if (ONpct11 < 10) StrONpct11 = "&nbsp" + StrONpct11; // add leading spaces

if (ONpct11 < 100) StrONpct11 = "&nbsp" + StrONpct11; // add leading spaces

client.println("11");

client.println(StrONtotal11);

client.println(StrONhour11);

client.println(StrONpct11);

client.println("<br>");

client.println("&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;");

String StrONtotal12 = String(ONtotal12);

if (ONtotal12 < 10) StrONtotal12 = "&nbsp" + StrONtotal12; // add leading spaces

if (ONtotal12 < 100) StrONtotal12 = "&nbsp" + StrONtotal12;

if (ONtotal12 < 1000) StrONtotal12 = "&nbsp" + StrONtotal12;

if (ONtotal12 < 10000) StrONtotal12 = "&nbsp" + StrONtotal12;

String StrONhour12 = String(ONhour12);

if (ONhour12 < 10) StrONhour12 = "&nbsp" + StrONhour12; // add leading spaces

if (ONhour12 < 100) StrONhour12 = "&nbsp" + StrONhour12;

if (ONhour12 < 1000) StrONhour12 = "&nbsp" + StrONhour12;

String StrONpct12 = String(ONpct12);

if (ONpct12 < 10) StrONpct12 = "&nbsp" + StrONpct12; // add leading spaces

if (ONpct12 < 100) StrONpct12 = "&nbsp" + StrONpct12; // add leading spaces

client.println("12");

client.println(StrONtotal12);

client.println(StrONhour12);

client.println(StrONpct12);

client.println("&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;");

client.println(" Well ");

client.println(wellwater);

client.println("<br>");

client.println("&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;");

String StrONtotal13 = String(ONtotal13);

if (ONtotal13 < 10) StrONtotal13 = "&nbsp" + StrONtotal13; // add leading spaces

if (ONtotal13 < 100) StrONtotal13 = "&nbsp" + StrONtotal13;

if (ONtotal13 < 1000) StrONtotal13 = "&nbsp" + StrONtotal13;

if (ONtotal13 < 10000) StrONtotal13 = "&nbsp" + StrONtotal13;

String StrONhour13 = String(ONhour13);

if (ONhour13 < 10) StrONhour13 = "&nbsp" + StrONhour13; // add leading spaces

if (ONhour13 < 100) StrONhour13 = "&nbsp" + StrONhour13;

if (ONhour13 < 1000) StrONhour13 = "&nbsp" + StrONhour13;

String StrONpct13 = String(ONpct13);

if (ONpct13 < 10) StrONpct13 = "&nbsp" + StrONpct13; // add leading spaces

if (ONpct13 < 100) StrONpct13 = "&nbsp" + StrONpct13; // add leading spaces

client.println("13");

client.println(StrONtotal13);

client.println(StrONhour13);

client.println(StrONpct13);

client.println("<br>");

client.println("&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;");

String StrONtotal14 = String(ONtotal14);

if (ONtotal14 < 10) StrONtotal14 = "&nbsp" + StrONtotal14; // add leading spaces

if (ONtotal14 < 100) StrONtotal14 = "&nbsp" + StrONtotal14;

if (ONtotal14 < 1000) StrONtotal14 = "&nbsp" + StrONtotal14;

if (ONtotal14 < 10000) StrONtotal14 = "&nbsp" + StrONtotal14;

String StrONhour14 = String(ONhour14);

if (ONhour14 < 10) StrONhour14 = "&nbsp" + StrONhour14; // add leading spaces

if (ONhour14 < 100) StrONhour14 = "&nbsp" + StrONhour14;

if (ONhour14 < 1000) StrONhour14 = "&nbsp" + StrONhour14;

String StrONpct14 = String(ONpct14);

if (ONpct14 < 10) StrONpct14 = "&nbsp" + StrONpct14; // add leading spaces

if (ONpct14 < 100) StrONpct14 = "&nbsp" + StrONpct14; // add leading spaces

client.println("14");

client.println(StrONtotal14);

client.println(StrONhour14);

client.println(StrONpct14);

client.println("<br>");

client.println("&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;");

String StrONtotal15 = String(ONtotal15);

if (ONtotal15 < 10) StrONtotal15 = "&nbsp" + StrONtotal15; // add leading spaces

if (ONtotal15 < 100) StrONtotal15 = "&nbsp" + StrONtotal15;

if (ONtotal15 < 1000) StrONtotal15 = "&nbsp" + StrONtotal15;

if (ONtotal15 < 10000) StrONtotal15 = "&nbsp" + StrONtotal15;

String StrONhour15 = String(ONhour15);

if (ONhour15 < 10) StrONhour15 = "&nbsp" + StrONhour15; // add leading spaces

if (ONhour15 < 100) StrONhour15 = "&nbsp" + StrONhour15;

if (ONhour15 < 1000) StrONhour15 = "&nbsp" + StrONhour15;

String StrONpct15 = String(ONpct15);

if (ONpct15 < 10) StrONpct15 = "&nbsp" + StrONpct15; // add leading spaces

if (ONpct15 < 100) StrONpct15 = "&nbsp" + StrONpct15; // add leading spaces

client.println("15");

client.println(StrONtotal15);

client.println(StrONhour15);

client.println(StrONpct15);

client.println("<br>");

client.println("&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;");

String StrONtotal16 = String(ONtotal16);

if (ONtotal16 < 10) StrONtotal16 = "&nbsp" + StrONtotal16; // add leading spaces

if (ONtotal16 < 100) StrONtotal16 = "&nbsp" + StrONtotal16;

if (ONtotal16 < 1000) StrONtotal16 = "&nbsp" + StrONtotal16;

if (ONtotal16 < 10000) StrONtotal16 = "&nbsp" + StrONtotal16;

String StrONhour16 = String(ONhour16);

if (ONhour16 < 10) StrONhour16 = "&nbsp" + StrONhour16; // add leading spaces

if (ONhour16 < 100) StrONhour16 = "&nbsp" + StrONhour16;

if (ONhour16 < 1000) StrONhour16 = "&nbsp" + StrONhour16;

String StrONpct16 = String(ONpct16);

if (ONpct16 < 10) StrONpct16 = "&nbsp" + StrONpct16; // add leading spaces

if (ONpct16 < 100) StrONpct16 = "&nbsp" + StrONpct16; // add leading spaces

client.println("16");

client.println(StrONtotal16);

client.println(StrONhour16);

client.println(StrONpct16);

client.println("<br>");

client.println("&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;");

String StrONtotal17 = String(ONtotal17);

if (ONtotal17 < 10) StrONtotal17 = "&nbsp" + StrONtotal17; // add leading spaces

if (ONtotal17 < 100) StrONtotal17 = "&nbsp" + StrONtotal17;

if (ONtotal17 < 1000) StrONtotal17 = "&nbsp" + StrONtotal17;

if (ONtotal17 < 10000) StrONtotal17 = "&nbsp" + StrONtotal17;

String StrONhour17 = String(ONhour17);

if (ONhour17 < 10) StrONhour17 = "&nbsp" + StrONhour17; // add leading spaces

if (ONhour17 < 100) StrONhour17 = "&nbsp" + StrONhour17;

if (ONhour17 < 1000) StrONhour17 = "&nbsp" + StrONhour17;

String StrONpct17 = String(ONpct17);

if (ONpct17 < 10) StrONpct17 = "&nbsp" + StrONpct17; // add leading spaces

if (ONpct17 < 100) StrONpct17 = "&nbsp" + StrONpct17; // add leading spaces

client.println("17");

client.println(StrONtotal17);

client.println(StrONhour17);

client.println(StrONpct17);

client.println("<br>");

client.println("&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;");

String StrONtotal18 = String(ONtotal18);

if (ONtotal18 < 10) StrONtotal18 = "&nbsp" + StrONtotal18; // add leading spaces

if (ONtotal18 < 100) StrONtotal18 = "&nbsp" + StrONtotal18;

if (ONtotal18 < 1000) StrONtotal18 = "&nbsp" + StrONtotal18;

if (ONtotal18 < 10000) StrONtotal18 = "&nbsp" + StrONtotal18;

String StrONhour18 = String(ONhour18);

if (ONhour18 < 10) StrONhour18 = "&nbsp" + StrONhour18; // add leading spaces

if (ONhour18 < 100) StrONhour18 = "&nbsp" + StrONhour18;

if (ONhour18 < 1000) StrONhour18 = "&nbsp" + StrONhour18;

String StrONpct18 = String(ONpct18);

if (ONpct18 < 10) StrONpct18 = "&nbsp" + StrONpct18; // add leading spaces

if (ONpct18 < 100) StrONpct18 = "&nbsp" + StrONpct18; // add leading spaces

client.println("18");

client.println(StrONtotal18);

client.println(StrONhour18);

client.println(StrONpct18);

client.println("<br>");

client.println("&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;");

String StrONtotal19 = String(ONtotal19);

if (ONtotal19 < 10) StrONtotal19 = "&nbsp" + StrONtotal19; // add leading spaces

if (ONtotal19 < 100) StrONtotal19 = "&nbsp" + StrONtotal19;

if (ONtotal19 < 1000) StrONtotal19 = "&nbsp" + StrONtotal19;

if (ONtotal19 < 10000) StrONtotal19 = "&nbsp" + StrONtotal19;

String StrONhour19 = String(ONhour19);

if (ONhour19 < 10) StrONhour19 = "&nbsp" + StrONhour19; // add leading spaces

if (ONhour19 < 100) StrONhour19 = "&nbsp" + StrONhour19;

if (ONhour19 < 1000) StrONhour19 = "&nbsp" + StrONhour19;

String StrONpct19 = String(ONpct19);

if (ONpct19 < 10) StrONpct19 = "&nbsp" + StrONpct19; // add leading spaces

if (ONpct19 < 100) StrONpct19 = "&nbsp" + StrONpct19; // add leading spaces

client.println("19");

client.println(StrONtotal19);

client.println(StrONhour19);

client.println(StrONpct19);

client.println("<br>");

client.println("&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;");

String StrONtotal20 = String(ONtotal20);

if (ONtotal20 < 10) StrONtotal20 = "&nbsp" + StrONtotal20; // add leading spaces

if (ONtotal20 < 100) StrONtotal20 = "&nbsp" + StrONtotal20;

if (ONtotal20 < 1000) StrONtotal20 = "&nbsp" + StrONtotal20;

if (ONtotal20 < 10000) StrONtotal20 = "&nbsp" + StrONtotal20;

String StrONhour20 = String(ONhour20);

if (ONhour20 < 10) StrONhour20 = "&nbsp" + StrONhour20; // add leading spaces

if (ONhour20 < 100) StrONhour20 = "&nbsp" + StrONhour20;

if (ONhour20 < 1000) StrONhour20 = "&nbsp" + StrONhour20;

String StrONpct20 = String(ONpct20);

if (ONpct20 < 10) StrONpct20 = "&nbsp" + StrONpct20; // add leading spaces

if (ONpct20 < 100) StrONpct20 = "&nbsp" + StrONpct20; // add leading spaces

client.println("20");

client.println(StrONtotal20);

client.println(StrONhour20);

client.println(StrONpct20);

client.println("<br>");

client.println("&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;");

String StrONtotal21 = String(ONtotal21);

if (ONtotal21 < 10) StrONtotal21 = "&nbsp" + StrONtotal21; // add leading spaces

if (ONtotal21 < 100) StrONtotal21 = "&nbsp" + StrONtotal21;

if (ONtotal21 < 1000) StrONtotal21 = "&nbsp" + StrONtotal21;

if (ONtotal21 < 10000) StrONtotal21 = "&nbsp" + StrONtotal21;

String StrONhour21 = String(ONhour21);

if (ONhour21 < 10) StrONhour21 = "&nbsp" + StrONhour21; // add leading spaces

if (ONhour21 < 100) StrONhour21 = "&nbsp" + StrONhour21;

if (ONhour21 < 1000) StrONhour21 = "&nbsp" + StrONhour21;

String StrONpct21 = String(ONpct21);

if (ONpct21 < 10) StrONpct21 = "&nbsp" + StrONpct21; // add leading spaces

if (ONpct21 < 100) StrONpct21 = "&nbsp" + StrONpct21; // add leading spaces

client.println("21");

client.println(StrONtotal21);

client.println(StrONhour21);

client.println(StrONpct21);

client.println("<br>");

client.println("&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;");

String StrONtotal22 = String(ONtotal22);

if (ONtotal22 < 10) StrONtotal22 = "&nbsp" + StrONtotal22; // add leading spaces

if (ONtotal22 < 100) StrONtotal22 = "&nbsp" + StrONtotal22;

if (ONtotal22 < 1000) StrONtotal22 = "&nbsp" + StrONtotal22;

if (ONtotal22 < 10000) StrONtotal22 = "&nbsp" + StrONtotal22;

String StrONhour22 = String(ONhour22);

if (ONhour22 < 10) StrONhour22 = "&nbsp" + StrONhour22; // add leading spaces

if (ONhour22 < 100) StrONhour22 = "&nbsp" + StrONhour22;

if (ONhour22 < 1000) StrONhour22 = "&nbsp" + StrONhour22;

String StrONpct22 = String(ONpct22);

if (ONpct22 < 10) StrONpct22 = "&nbsp" + StrONpct22; // add leading spaces

if (ONpct22 < 100) StrONpct22 = "&nbsp" + StrONpct22; // add leading spaces

client.println("22");

client.println(StrONtotal22);

client.println(StrONhour22);

client.println(StrONpct22);

client.println("<br>");

client.println("&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;");

String StrONtotal23 = String(ONtotal23);

if (ONtotal23 < 10) StrONtotal23 = "&nbsp" + StrONtotal23; // add leading spaces

if (ONtotal23 < 100) StrONtotal23 = "&nbsp" + StrONtotal23;

if (ONtotal23 < 1000) StrONtotal23 = "&nbsp" + StrONtotal23;

if (ONtotal23 < 10000) StrONtotal23 = "&nbsp" + StrONtotal23;

String StrONhour23 = String(ONhour23);

if (ONhour23 < 10) StrONhour23 = "&nbsp" + StrONhour23; // add leading spaces

if (ONhour23 < 100) StrONhour23 = "&nbsp" + StrONhour23;

if (ONhour23 < 1000) StrONhour23 = "&nbsp" + StrONhour23;

String StrONpct23 = String(ONpct23);

if (ONpct23 < 10) StrONpct23 = "&nbsp" + StrONpct23; // add leading spaces

if (ONpct23 < 100) StrONpct23 = "&nbsp" + StrONpct23; // add leading spaces

client.println("23");

client.println(StrONtotal23);

client.println(StrONhour23);

client.println(StrONpct23);

// client.println(counter);

client.println("<br>");

client.println("<br>");

client.println("<br>"

"<br>"

"<br>"

"<br>"

"<br>"

"<br>"

"<br>"

"<br>"

"<br>"

"<br>"

"<br>"

"<br>"

"<br>"

"<br>"

"<br>"

"<br>"

"<br>"

"<br>"

"<br>"

"<br>"

"<br>"

"<br>"

"<br>"

"<br>"

"<br>"

"<br>"

"<br>"

"<br>"

"<br>"

"<br>"

"<br>"

"<br>"

"<br>"

"<br>"

"<br>"

"<br>"

"."); // add period below the background you want to display or it won't scroll past last text

client.println("</p>"

"</body>");

client.println("<br>");

client.println("</html>");

client.stop(); // disconnect client to allow other clients

delay(1);

//******************************************

}