Second half:
// if the file is available, write to it:
if (dataFile) {
dataFile.print(year());
dataFile.print("-");
dataFile.print(month());
dataFile.print("-");
dataFile.print(day());
dataFile.print(" ");
dataFile.print(hour());
dataFile.print(":");
dataFile.print(minute());
dataFile.print(":");
dataFile.print(second());
dataFile.print(",");
dataFile.print(sensors.getTempC(T01));
dataFile.print(",");
dataFile.print(sensors.getTempC(T02));
dataFile.print(",");
dataFile.print(sensors.getTempC(T04));
dataFile.print(",");
dataFile.print(sensors.getTempC(T07));
dataFile.print(",");
dataFile.print(sensors.getTempC(T08));
dataFile.print(",");
dataFile.print(sensors.getTempC(T09));
dataFile.print(",");
dataFile.print(sensors.getTempC(T05));
dataFile.print(",");
dataFile.print(sensors.getTempC(T06));
dataFile.print(",");
dataFile.print(digitalRead(R01)*-1+1);
dataFile.print(",");
dataFile.println(digitalRead(R02)*-1+1);
dataFile.close();
}
// if the file isn't open, pop up an error:
else {
Serial.println("error opening .txt file");
}
//ETHERNET webpage output:
Client client = server.available();
if (client) {
// an http request ends with a blank line
boolean current_line_is_blank = true;
while (client.connected()) {
if (client.available()) {
char c = client.read();
if (c == '\n' && current_line_is_blank) {
client.println("HTTP/1.1 200 OK");
client.println("Content-Type: text/html");
client.println();
//Temp etc readings fow webpage:
{
client.print("<h1>Heating Control System Status</h1>");
client.print("<body style=\"background-color:PowderBlue;\">");
client.print("<table border=\"1\"><tr><td>Outside Temp: </td><td>");
client.print(sensors.getTempC(T01));
client.print("</td></tr>"); //end table row
client.print("<tr><td>Downtstairs Hall Temp: </td><td>");
client.print(sensors.getTempC(T02));
client.print("</td></tr>"); //end table row
client.print("<tr><td>Centraliser Temp: </td><td>");
client.print(sensors.getTempC(T04));
client.print("</td></tr>"); //end table row
client.print("<tr><td>Hot Water Top Temp: </td><td>");
client.print(sensors.getTempC(T07));
client.print("</td></tr>"); //end table row
client.print("<tr><td>Hot Water Mid Temp: </td><td>");
client.print(sensors.getTempC(T08));
client.print("</td></tr>"); //end table row
client.print("<tr><td>Hot Water Bottom Temp: </td><td>");
client.print(sensors.getTempC(T09));
client.print("</td></tr>"); //end table row
client.print("<tr><td>WBS Flow Temp: </td><td>");
client.print(sensors.getTempC(T05));
client.print("</td></tr>"); //end table row
client.print("<tr><td>WBS Return Temp: </td><td>");
client.print(sensors.getTempC(T06));
client.print("</td></tr>"); //end table row
client.print("<tr><td>CH Pump Status: </td><td>");
R01Status = digitalRead(R01);
if (R01Status = HIGH) {client.print("Off");}
else client.print("On");
client.print("</td></tr>"); //end table row
client.print("<tr><td>WBS Pump Status: </td><td>");
R02Status = digitalRead(R02);
if (R02Status = HIGH) {client.print("Off");}
else client.print("On");
client.print("</td></tr>"); //end table row
delay(1000);
}
break;
}
if (c == '\n') {
current_line_is_blank = true;
}
else if (c != '\r') {
current_line_is_blank = false;
}
}
}
delay(1);
client.stop();
}
//LCD ########
buttonState = digitalRead(buttonPin); //if button is pushed or not
{if (buttonState == LOW){ //LOW = button pressed
lcd.init();
lcd.backlight();
lcd.setCursor(0,0);
lcd.print("Central = ");
lcd.print(sensors.getTempC(T04));
lcd.setCursor(0,1);
lcd.print("CH Pump = ");
lcd.print((digitalRead(R01) * -1 +1));
delay(2000);
lcd.clear();
lcd.setCursor(0,0);
lcd.print("HW Top = ");
lcd.print(sensors.getTempC(T07));
lcd.setCursor(0,1);
lcd.print("HW Mid = ");
lcd.print(sensors.getTempC(T08));
delay(2000);
lcd.clear();
lcd.setCursor(0,0);
lcd.print("WBS = ");
lcd.print(sensors.getTempC(T06));
lcd.print(" / ");
lcd.print(sensors.getTempC(T05));
lcd.setCursor(0,1);
lcd.print("WBS Pump = ");
lcd.print((digitalRead(R02) * -1 +1));
delay(2000);
lcd.clear();}
else { //turn of display if button not pressed
lcd.noDisplay();
lcd.noBacklight();
}}
}