//declare variables
int imm = 65;
int coil = 53;
int flow = 47;
int und = 62;
int mix = 57;
int hyst = 3;
int hyst1 =6;
int hyst2 =10;
float tempTop;
float tempMid;
float tempBot;
float tempFlow;
float tempRet;
float tempSol;
int tempPin = 0;
int tempPin1 = 1;
int tempPin2 = 2;
int tempPin3 = 3;
int tempPin4 = 4;
int NeutValve = 2; // Valve from neutralizer to Cylinder
int MPump = 3; // Mixer Pump
int HeatPump = 4; // Central Heating Main Pump
int ImmOn = 6; //Relay confirming Immersion running
int GasBoiler = 7; // Gas boiler run output
int UndFlor = 8; // Underfloor heating run output
int GasBurn = 9; // Gas Boiler run contact.
int Imm = 10; // Immersion Heater control
int FlorLiv = 11; // Underfloor Heating Living Room Output
void setup()
{
Serial.begin(9600); //opens serial port, sets data rate to 9600 bps
pinMode(3, OUTPUT);
pinMode(2, OUTPUT);
pinMode(4, OUTPUT);
pinMode(5, OUTPUT);
pinMode(6, INPUT);
pinMode(7,OUTPUT);
pinMode(8,OUTPUT);
pinMode(9,INPUT);
pinMode(10,OUTPUT);
pinMode(11,OUTPUT);
}
void loop()
{
Serial.println("");
tempTop = analogRead(tempPin); //read the value from the Cylinder Top sensor
tempTop = (5.0 * tempTop * 100.0)/1024.0+6; //convert the analog data to temperature
Serial.print((byte)tempTop);
Serial.println(" *C Cylinder Top");//send the data to the computer
tempMid = analogRead(tempPin1); //read the value from the sensor Cylinder Middle
tempMid = (5.0 * tempMid * 100.0)/1024.0+8; //convert the analog data to temperature
Serial.print((byte)tempMid);
Serial.println(" *C Cylinder Middle");//send the data to the computer
//tempBot = analogRead(tempPin2); //read the value from the sensor Cylinder Bottom
//tempBot = (5.0 * tempBot * 100.0)/1024.0; //convert the analog data to temperature
//Serial.print((byte)tempBot);
//Serial.println(" *C Cylinder Bottom");//send the data to the computer
tempFlow = analogRead(tempPin3); //read the value from the sensor Neutraziler Flow Temp
tempFlow = (5.0 * tempFlow * 100.0)/1024.0; //convert the analog data to temperature
Serial.print((byte)tempFlow);
Serial.println(" *C Flow Temp");//send the data to the computer
tempRet = analogRead(tempPin4); //read the value from the sensor Return Temp
tempRet = (5.0 * tempRet * 100.0)/1024.0; //convert the analog data to temperature
Serial.print((byte)tempRet);
Serial.println(" *C Return Temp");//send the data to the computer
int ImmOn1 = digitalRead (ImmOn);
Serial.print (" Immersion On ");
Serial.println(ImmOn1);
int Pump1 = digitalRead (HeatPump);
Serial.print (" Central Heating Pump On ");
Serial.println(Pump1);
int Pump2 = digitalRead (UndFlor);
Serial.print ("Underfloor Heating ON ");
Serial.println(Pump2);
int Coil1 = digitalRead (NeutValve);
Serial.print ("Water Heating Coil Reversed ");
Serial.println(Coil1);
if (Imm == HIGH) Serial.print ("IMM Contact ");
else Serial.println (" IMM No Contact ");
int Mix1 = digitalRead (MPump);
Serial.print ("mixer pump");
if (Mix1 == HIGH) Serial.print ("Mixing");
else Serial.print(" no mix");
delay(2000); //wait one second before sending new data
// Heating Circulating pump
if (tempRet > flow + hyst1)
digitalWrite(HeatPump, HIGH);
if (tempRet < flow - hyst1)
digitalWrite(HeatPump, LOW);
// Underfloor Heating Control
if (tempFlow > (und + hyst))
digitalWrite (UndFlor, HIGH);
if (tempFlow < (und - hyst2))
digitalWrite (UndFlor, LOW);
//Over Temperature Protection
if (tempFlow > 85)
digitalWrite (FlorLiv, HIGH);
if (tempFlow < 65)
digitalWrite (FlorLiv, LOW);
// Neutralizer Valve Control
if(tempTop >(coil + hyst)) // Neutralizer to Cylinder Valve Close Temperature
digitalWrite(NeutValve, HIGH);
if (tempTop <(coil - hyst)) // Neutralizer to Cylinder Open Temperature
digitalWrite(NeutValve, LOW);
// Immersion Control
if (tempTop >( imm + hyst)) // Immersion Temperature Off
digitalWrite(Imm,LOW );
else if (tempTop <( imm - hyst)) // Immersion on Temperature
digitalWrite(Imm, HIGH);
// Cylinder Circulating Pump Control
if (tempTop < (mix + hyst) && (ImmOn == HIGH))
digitalWrite (MPump, HIGH);
if (tempTop >(mix - hyst) || (ImmOn == LOW))
digitalWrite (MPump, LOW);
}