The code in the main control panel is fairly standard except for the part which sends data down the I2C bus to the Adafruit Feather slave. This code can be found in 'void sendData()' below and involves disassembling complex float numbers eg 89.29 and turning them into a string and then using character manipulation to turn them into a seires of individual integer digits, ie 8 ...9 ...2 ...9. To make it even more complicated, each series of integers had to have an identification marker so that the slave could recognise that a particular stream of digits had been initiated and it had to also have a number representing the number of digits being sent (string length) AND, just to completely fry my already half cooked brain, the digits themselves had to be sent back to front!

#include <Adafruit_ADS1015.h> #include <OneWire.h> #include <DallasTemperature.h> #include <Wire.h> #include <LiquidCrystal.h> #define ONE_WIRE_BUS 10 #define TEMPERATURE_PRECISION 12 OneWire oneWire(ONE_WIRE_BUS); DallasTemperature sensors(&oneWire); DeviceAddress sensor0,sensor1,sensor2,sensor3; char digitCharAAAA[10]; char digitCharBBBB[10]; String testAA; String nothing; // This is important - the string precursor. String testAAAA; // File names need to be of sufficient complexity! String testBBBB; int stringLengthAA; int numberId =101; int dataPrecursor = 198; // A randomish number below 254. Be careful it does not conflict with numberIds. int digitAAAA; float tempZ=20.01; int n = 0; unsigned long currentTime=0; unsigned long previousTime=0; unsigned long intervalTime=0; float tempC; int deviceCount =0; float boilerTemp; float refluxTemp; float hydroTemp; float condensorTemp; float previousTempC =0; float totalTempC=0; float deltaTempC =0; float previousDeltaTempC =0; float doubleDeltaTempC =0; Adafruit_ADS1115 ads; /* Use this for the 16-bit version */ // Adafruit_ADS1015 ads; /* Use thi for the 12-bit version */ LiquidCrystal lcd(12, 11, 5, 4, 3, 2); byte delta[8] = { B00000, B00100, B00100, B01010, B01010, B10001, B11111, B00000 }; byte percent[8] = { B11001, B11010, B00010, B00100, B00100, B01000, B01011, B10011 }; const int analogInPin = A0; // Analog input pin that the potentiometer is attached to const int densityEthanol = 789; long sensorValue = 0; // value read from the pot int outputValue = 0; // value output to the PWM (analog out) int outputValueMin = 1000; int outputValueMax = -1000; int loopToStart =0; int a=0; int i=0; int k=0; int c=0; int x=0; int z=0; int y=5; int h=0; int f=0; int T00=0; int T01=0; int T02=0; int T03=0; int T04=0; int T05=0; float endTemp =0; int alcoholCount=0; float alcoholX=10.00; int alcoholLimit=550; double potReading01=0; double pumpTimer1=0; double pumpTimer2=0; int pumpTimer3=1; int pumpTimer4=0; int adjustmentTimer=200; int mappedPotReading01=0; int potReading02=0; int mappedPotReading02=0; int potReading03=0; double powerFactor=0; int levelSwitch =HIGH; int foreshotsDumpValue =0; int startAndEndDumpValue =0; int tempCount=0; int momentarySwitchStatus =0; int mins=0; double ethanol =0; float av=0; long totalAdjustedOutputValue=0; int adjustedOutputValue = 0; float hrs=1; double pressure =0; double avPressure =0; //Digital pins: //D13: //D12:LCD //D11:LCD //D10:TEMP01 //D09:Relay //D08:Dump relay //D07:Relay for equalising hydrometer pressure //D06:Heater relay //D05:LCD //D04:LCD //D03:LCD //D02:LCD //Analogue pins: //A0:Tone //A1:Pot //A2:Pot //A3:Pot //A7:Alcohol void setup() { pinMode(A8, INPUT_PULLUP); // Boiler level switch pinMode(6, OUTPUT); // Relay for heater digitalWrite(6, LOW); pinMode(8, OUTPUT); // Relay for dump valve. digitalWrite(8, LOW); pinMode (13, OUTPUT); // Relay digitalWrite(13, LOW); pinMode (7, OUTPUT); // Relay digitalWrite(7, LOW); pinMode (9, OUTPUT); // Relay digitalWrite(9, LOW); // External relays: 47,49,51,53 pinMode(47, OUTPUT); // Relay for NOT USED digitalWrite(47, HIGH); pinMode(49, OUTPUT); // Relay for PUMP digitalWrite(49, HIGH); pinMode(51, OUTPUT); // Relay for RH valve digitalWrite(51, HIGH); pinMode(53, OUTPUT); // Relay for LH valve digitalWrite(53, HIGH); // pinMode (A1, OUTPUT); //SFX T02 alcohol levels exceeded // pinMode (A2, OUTPUT); //SFX T03 seventy degrees // pinMode (A3, OUTPUT); //SFX T04 ninety five degrees pinMode (23, OUTPUT); //SFX .............. pinMode (25, OUTPUT); //SFX ..............Finished pinMode (27, OUTPUT); //SFX ..............Alcohol too high pinMode (29, OUTPUT); //SFX ..............70 degrees pinMode (31, OUTPUT); //SFX ..............95 degrees pinMode (33, OUTPUT); //SFX ..............Heater turned on pinMode (35, OUTPUT); //SFX ..............Process initiated pinMode (37, OUTPUT); //SFX ..............Dump valve opened pinMode (39, OUTPUT); //SFX ..............Temperature is rising pinMode (41, OUTPUT); //SFX ..............Now producing alcohol pinMode (43, OUTPUT); //SFX .............. //SFX T06 //SFX T07 // digitalWrite(A1, HIGH); // digitalWrite(A2, HIGH); // digitalWrite(A3, HIGH); digitalWrite(23, HIGH); digitalWrite(25, HIGH); digitalWrite(27, HIGH); digitalWrite(29, HIGH); digitalWrite(31, HIGH); digitalWrite(33, HIGH); digitalWrite(35, HIGH); digitalWrite(37, HIGH); digitalWrite(39, HIGH); digitalWrite(41, HIGH); digitalWrite(43, HIGH); digitalWrite(35, LOW); delay(500); digitalWrite(35, HIGH); // digitalWrite(11, HIGH); Serial.begin(115200); lcd.createChar(1, delta); lcd.createChar(2, percent); lcd.begin(20, 4); lcd.setCursor(0,0); lcd.print(" DISTILLATION "); lcd.setCursor(0,1); lcd.print(" INITIATED "); ////////////////////////////////Wait for MQ3 to warm up ////////////////////////////////////////// delay(3000); alcoholX = analogRead(A7); while (alcoholX>alcoholLimit) { alcoholX = analogRead(A7); tone (A0,alcoholX*2,200); delay(500); lcd.setCursor(0,0); lcd.print("Wait for MQ3 Heater "); lcd.setCursor(0,1); lcd.print(" "); lcd.setCursor(0,2); lcd.print("Alcohol:"); lcd.setCursor(9,2); lcd.print(alcoholX); } ////////////////////////////////////////////////////////////////////////////////////////////////// //Temperature stuff sensors.begin(); // locate devices on the bus Serial.print("Locating devices..."); Serial.print("Found "); deviceCount = sensors.getDeviceCount(), DEC; Serial.print(deviceCount); Serial.println(" devices."); if (!sensors.getAddress(sensor0, 0)) Serial.println("Unable to find address for Device 0"); if (!sensors.getAddress(sensor1, 1)) Serial.println("Unable to find address for Device 1"); if (!sensors.getAddress(sensor2, 2)) Serial.println("Unable to find address for Device 2"); if (!sensors.getAddress(sensor3, 3)) Serial.println("Unable to find address for Device 3"); sensors.setResolution(sensor0, TEMPERATURE_PRECISION); sensors.setResolution(sensor1, TEMPERATURE_PRECISION); sensors.setResolution(sensor2, TEMPERATURE_PRECISION); sensors.setResolution(sensor3, TEMPERATURE_PRECISION); Serial.print("Device 0 Address: "); printAddress(sensor0); Serial.println(); Serial.print("Device 1 Address: "); printAddress(sensor1); Serial.println(); Serial.print("Device 2 Address: "); printAddress(sensor2); Serial.println(); Serial.print("Device 3 Address: "); printAddress(sensor3); Serial.println(); Serial.println(""); printTemperature(); lcdTemperatures(); delay (4000); ////////////////////////////////////////////////////////////////////////////////////////////////// pinMode(28, INPUT_PULLUP); // Momentary switch ads.begin(); previousTempC = tempC; totalTempC = -1*tempC; delay (4000); digitalWrite(8, LOW); lcd.clear(); } /////////////////////////////////////////////////////////////////////////////////////////// void loop() { /////////////////////////////////////////////////////////////////////////////////////////////// // Send data to the Feather Nestbox every 2 minutes: currentTime = millis(); intervalTime = currentTime - previousTime; Serial.print("Current time: "); Serial.print(currentTime/1000);Serial.print(" Secs ");Serial.print(currentTime/60000);Serial.println(" Minutes"); if (intervalTime > 120000) { // Send data to the feather HERE. ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// Serial.println("Now we are doing a transmission ....... "); Serial.println(""); lcd.setCursor(0,3); lcd.print("Transmitting data..."); delay(3000); Wire.beginTransmission(9); // transmit to device #9 // Make sure the order is the same in master and slave. delay(20); // We're going to send two chunks of data, tempA and tempB. Each of them is less than 1,000 and has two digits after the //decimal place. tempZ=boilerTemp; numberId= 101; sendData(); Serial.print(numberId);Serial.print(": ");Serial.println(tempZ); delay(50); tempZ=refluxTemp; numberId= 102; sendData(); Serial.print(numberId);Serial.print(": ");Serial.println(tempZ); delay(50); tempZ=condensorTemp; numberId= 103; sendData(); Serial.print(numberId);Serial.print(": ");Serial.println(tempZ); delay(50); tempZ=hydroTemp; numberId= 104; sendData(); Serial.print(numberId);Serial.print(": ");Serial.println(tempZ); delay(50); Wire.endTransmission(); Wire.beginTransmission(9); // transmit to device #9 // Make sure the order is the same in master and slave. delay(20); tempZ=mins; numberId= 107; sendData(); delay(20); tempZ=alcoholX/10; numberId= 105; sendData(); Serial.print(numberId);Serial.print(": ");Serial.println(tempZ); tempZ=pressure/10; numberId= 106; sendData(); while (k<20) { tone (A0,700,50); delay(100); k++; } k=0; Serial.print(numberId);Serial.print(": ");Serial.println(tempZ); delay(50); Wire.endTransmission(); Serial.println(""); Serial.println("Transmission ended ....... "); Serial.println(""); previousTime=currentTime; } /////////////////////////////////////////////////////////////////////////////////////////////// int momentarySwitch = digitalRead(28); if ((momentarySwitch == LOW)&&(momentarySwitchStatus == 0)) { momentarySwitchStatus=1; } else { if ((momentarySwitch == LOW)&&(momentarySwitchStatus == 1)) { momentarySwitchStatus=0; } } /////////////////////////////////////////////////////////////////////////////////////////// ///////////////////////////// if command encompases all the next code ///////////////////// if (momentarySwitchStatus==0) { //////////////////////////////////////////////////////////////////////////////////////////// // Test external relays //////////////////////////////////////////////////////////////////// // digitalWrite(53, LOW); // delay(5000); // digitalWrite(53, HIGH); ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// //////// A place to allow settings to be adjusted /////////////////////////////////////////////////////////////////////////// while (adjustmentTimer>0) { tone(A0,(adjustmentTimer*2)+600,50); potReading01 = analogRead(A1); pumpTimer4 = potReading01; lcd.setCursor(0,0); lcd.print("Pump timer:"); lcd.setCursor(12,0); lcd.print(" "); lcd.setCursor(12,0); lcd.print(pumpTimer4); lcd.setCursor(15,0); lcd.print("secs"); lcd.setCursor(0,1); lcd.print("Alcohol limit:"); lcd.setCursor(15,1); lcd.print(alcoholLimit); potReading03 = analogRead(A3); powerFactor = map(potReading03, 14, 1023, 0, 100); lcd.setCursor(0,2); lcd.print("Power factor:"); lcd.setCursor(14,2); lcd.print(powerFactor); lcd.setCursor(18,2); lcd.write(2); potReading02 = analogRead(A2); mappedPotReading02 = map(potReading02, 13, 1023, 0, 1000); endTemp = (mappedPotReading02 / 200.00) + 98.00; lcd.setCursor(0,3); lcd.print("End Temp: "); lcd.setCursor(10,3); lcd.print(endTemp,2); lcd.setCursor(16,3); lcd.print("\337C"); adjustmentTimer=adjustmentTimer-1; delay(100); } ///////////////////////////////// Reading potentiometer on A1: Unused /////////////////////////////////////////////////////// if (loopToStart ==0) { lcd.clear(); potReading01 = analogRead(A1); lcd.setCursor(0,2); lcd.print("Pump in timer:"); lcd.setCursor(5,3); pumpTimer4 = potReading01; lcd.print(pumpTimer4); lcd.print(" seconds "); } //////////////////////////////////////////////////////////////////////////////////////////// ///// Empty the boiler. Fluid exits from LH valve port 3 ///////////////////////////////////////////////////////////////////// pumpTimer1 = 1000*potReading01; pumpTimer2 = 1000*potReading01; if (loopToStart ==0) { //Pump and valves: //Valve default state is port 1 to 3 open. while (pumpTimer1>0) { levelSwitch = digitalRead(A8); if (levelSwitch == HIGH) { tone(A0,800,500); Serial.print("Level switch: "); Serial.println(levelSwitch); } pumpTimer1=pumpTimer1-1000; lcd.setCursor(0,0); lcd.print(" PUMPING OUT "); lcd.setCursor(0,1); lcd.print(" "); lcd.setCursor(5,1); pumpTimer3 = pumpTimer1/1000; lcd.print(pumpTimer3); digitalWrite(49, LOW); // Pump delay(1000); //Effectively mappedPotReading01 is in seconds. } lcd.setCursor(0,1); lcd.print(" COMPLETED "); digitalWrite(49, HIGH); } delay(5000); //////////////////////////////////////////////////////////////////////////////////////////// ///// Fill the boiler. Fluid enters from RH valve port 2 ///////////////////////////////////////////////////////////////////// pumpTimer3 =1; if ((loopToStart ==0)&&(pumpTimer3>0)) // &&(levelSwitch==LOW) { // digitalWrite(49, LOW); // Pump // digitalWrite(51, LOW); // LH valve digitalWrite(53, LOW); // RH valve must be opened before the pump starts. // delay(5000); // digitalWrite(49, HIGH); // digitalWrite(51, HIGH); // digitalWrite(53, HIGH); delay(2000); while ((pumpTimer3>0) && (levelSwitch==LOW)) { levelSwitch = digitalRead(A8); tone(A0,800,500); pumpTimer2=pumpTimer2-1000; lcd.setCursor(0,2); lcd.print(" PUMPING IN "); lcd.setCursor(0,3); lcd.print(" "); lcd.setCursor(5,3); pumpTimer3 =pumpTimer2/1000; lcd.print(pumpTimer3); lcd.setCursor(9,3); lcd.print(" Seconds "); digitalWrite(49, LOW); // Pump digitalWrite(51, LOW); //LH valve digitalWrite(53, LOW); delay(1000); } } if (loopToStart ==0) { lcd.setCursor(0,3); lcd.print(" COMPLETED "); digitalWrite(49, HIGH); digitalWrite(51, HIGH); digitalWrite(53, HIGH); delay(5000); lcd.clear(); } loopToStart=1; // This stops the pumping processes repeating in every loop. /////////////////////////////////////////////////////////////////////////////////////////////////// ///// Dump the contents of the hydrometer at the start //////////////////////////////////////////// startAndEndDump(); //////////////////////////////////////////////////////////////////////////////////////////// ////////////////// Changes the Beep when alcohol starts to be produced ///////////////////// if (pressure < 400) { tone (A0,tempC*40,500); } else { k=10; while (k<20) { tone (A0,tempC*k,50); delay(50); k++; } if (a==0) // One off Producing alcohol SFX. { digitalWrite(41, LOW); delay(500); digitalWrite(41, HIGH); a=1; } } ////////////////////////////////////////////////////////////////////////////////////////////////////////////////// ///////////////////////////////// Reading potentiometer on A2: End point temperature /////////////////////////////////////////////////////// potReading02 = analogRead(A2); mappedPotReading02 = map(potReading02, 13, 1023, 0, 1000); endTemp = (mappedPotReading02 / 200.00) + 98.00; delay(100); lcd.setCursor(0,0); lcd.print("End Temp: "); lcd.setCursor(11,0); lcd.print(endTemp,2); lcd.setCursor(18,0); lcd.print("\337C"); // Serial.println(endTemp,2); ////////////////////////////////////////////////////////////////////////////////////////////////////////////////// ///////////////////////////////// Reading potentiometer on A3: Heater power factor % /////////////////////////////////////////////////////// potReading03 = analogRead(A3); powerFactor = map(potReading03, 14, 1023, 0, 100); lcd.setCursor(0,1); lcd.print("Power factor: "); lcd.setCursor(14,1); lcd.print(powerFactor); lcd.setCursor(18,1); lcd.write(2); ///////////////////////////////////// Row 4 of LCD //////////////////////////////////////////////////////////////// lcd.setCursor(0,3); lcd.print(" "); ///////////////////////////////////////////////////////////////////////////////////////////// delay (1000); lcdStuff(); ///////////////////////////////// Now producing alcohol SFX /////////////////////////////////////////////////////// if ((tempCount==30)&&(pressure>100)) { digitalWrite(41, LOW); delay(500); digitalWrite(41, HIGH); } Serial.print("tempcount: ");Serial.println(tempCount); ///////////////////////////////////////////////////////////////////////////////////////////// //////////////////////////////// The process needs to finish //////////////////////////////// if (tempC > endTemp) { digitalWrite(6, LOW); // startAndEndDumpValue=0; // startAndEndDump(); while (1) { lcd.setCursor(0,0); lcd.print(" FINISHED "); digitalWrite(25,LOW); delay(1000); digitalWrite(25,HIGH); delay(10000); } } else { digitalWrite(A0,HIGH); } ///////////////////////////////////////////////////////////////////////////////////////////// alcoholX = analogRead(A7)*1.01; Serial.print("Alcohol: ");Serial.println(alcoholX); if (alcoholX>alcoholLimit) { while (alcoholX>alcoholLimit) { digitalWrite(6, LOW); lcdStuff(); alcoholX = analogRead(A7); digitalWrite(27, LOW); // SFX delay(500); digitalWrite(27, HIGH); delay (10000); } } else { digitalWrite(A1, HIGH); } if (alcoholX<alcoholLimit) { alcoholCount++; } else { alcoholCount=0; } ///////////////////////////////////////////////////////////////////////////////////////////// /////////// Heater control for full power://///////////////////////////////////////////////// if ((alcoholX<650)&&(alcoholCount>5)&&(tempC<85)) { digitalWrite(6, HIGH); if (T05==0) // Make a one off audio sound { digitalWrite(33, LOW); delay(500); digitalWrite(33, HIGH); T05=1; lcd.clear(); } } // else // { // digitalWrite(6, LOW); // T05=0; // } ///////////////////////////////////////////////////////////////////////////////////////////// /////////// Heater control for 1/5 power:////////////////////////////////////////////////////////////////// if ((alcoholX<650)&&(alcoholCount>10)&&(tempC>85)&&(condensorTemp<50)) { digitalWrite(6, LOW); delay (1000); digitalWrite(6, HIGH); delay (powerFactor*250); digitalWrite(6, LOW); } Serial.print("Power Factor: "); Serial.println(powerFactor,2); // else // { // digitalWrite(6, LOW); // } //////////////////////////////////////////////////////////////////////////////////////////////// if (condensorTemp>50) { digitalWrite(6, LOW); lcd.setCursor(0,3); lcd.print("Condensor too hot"); } /////////////////////////////////////////////////////////////////////////////////////////////////// ////////////////////////////////// One off SFX //////////////////////////////////////////////////// if ((tempC>70)&&(T03==0)) { digitalWrite(29, LOW); delay(500); digitalWrite(29, HIGH); T03=1; } else { digitalWrite(A2, HIGH); } /////////////////////////////////////////////////////////////////////////////////////////////////// ////////////////////////////////// One off SFX //////////////////////////////////////////////////// if ((tempC>95)&&(T04==0)) { digitalWrite(31, LOW); delay(500); digitalWrite(31, HIGH); T04=1; } else { digitalWrite(A3, HIGH); } ////////////////////////////////////////////////////////////////////////////////////////////////// foreshotsDump(); /////////////////////////////////////////////////////////////////////////////////////////////////// if (f==5) { pressureZeroing(); } sensors.requestTemperatures(); // Send the command to get temperatures printTemperature(); totalTempC = totalTempC + tempC; ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// int pushButton = digitalRead(10); if (pushButton == HIGH) { // Serial.print("Switch Off"); digitalWrite(8, LOW); } else { // Serial.print("Switch On"); // pressureZeroing(); digitalWrite(8, HIGH); } // Serial.println(" "); ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// ///////// Reading the hydrometer pressure sensor //////////////////////////////////////////////////////////////////////////// int16_t adc0, adc1, adc2, adc3; // adc0 = ads.readADC_SingleEnded(0); // Serial.print("AIN0: "); Serial.println(adc0); // Serial.println(" "); i=0; c++; sensorValue =0; while (i<15) { adc0 = analogRead(11); i++; sensorValue = sensorValue + adc0; delay (50); } sensorValue = sensorValue/i; // sensorValue = adc0; // Map it to the range of the analog out: //outputValue = map(sensorValue, 0, 1024, -2500, 2500); adjustedOutputValue = (sensorValue-512)*2.2; // Needs to be active in the range 0 to 1,000. pressure = adjustedOutputValue; Serial.print("Pressure sensor = "); // The sensor usually reads about 512 ie 1024/2. Serial.print(sensorValue); Serial.print("\t Actual output = "); Serial.println(pressure); if (adjustedOutputValue > outputValueMax) { outputValueMax = adjustedOutputValue; } if (adjustedOutputValue < outputValueMin) { outputValueMin = adjustedOutputValue; } totalAdjustedOutputValue = adjustedOutputValue + totalAdjustedOutputValue; av = 1.000*totalAdjustedOutputValue/c; avPressure = av/1.607/1.284; ethanol = 100 - (avPressure - densityEthanol) / (1000 - densityEthanol) *100; mins = c/60; /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// ////////////// Calculating the temperature changes value (delta T) //////////////////////////////////////////////////// if (tempCount ==10) { deltaTempC = totalTempC/10 - previousTempC; previousTempC = totalTempC/10; doubleDeltaTempC = deltaTempC - previousDeltaTempC; previousDeltaTempC = deltaTempC; if (deltaTempC >0.2) { digitalWrite(39, LOW); // SFX (Temperature is rising .... Checking all systems are operational.) delay(500); digitalWrite(39, HIGH); } // Serial.print(k); // Serial.print(","); // Serial.print(totalTempC/60); // Serial.print(","); // Serial.print(deltaTempC); // Serial.print(","); // Serial.println(pressure,0); // Serial.print("Ethanol%: "); // Serial.println(ethanol,0); z=10; y=0; totalTempC=0; /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// ////////////////////////// Zeroing the hydrometer sensor at 70 degrees C ////////////////////////////////////////////// if ((tempC>70)&&(h<1)) { pressureZeroing(); h=1; } tempCount=0; k++; } ///////////////////////////////////////////////////////////////////////////////////////////////////////// ////////////////////////// Print to LCD ///////////////////////////////////////////////////////////////// lcdTemperatures(); delay(5000); lcdStuff(); delay(5000); tempCount++; f++; } ////// The curly bracket above is effectively the main loop except for small bit of code below ///////////// /////////////////////////////////////////////////////////////////////////////////////////////////////////// ////////////////// Momentary switch stuff below here /////////////////////////////////////////////////////// else { paused(); delay(1000); } } /////////////////////////////////////////////////////////////////////////////////////////////////////////// void paused() { digitalWrite(6, LOW); // Turn off heater. digitalWrite(8, LOW); // Close dump valve. alcoholX = analogRead(A7); sensors.requestTemperatures(); // Send the command to get temperatures printTemperature(); lcd.setCursor(0,0); lcd.print(" PAUSED "); lcd.setCursor(0,1); lcd.print(" "); lcd.setCursor(0,2); lcd.print(" "); lcd.setCursor(0,3); lcd.print(" "); lcd.setCursor(0,0); lcd.print("P:"); delay(10); lcd.setCursor(2,0); lcd.print(pressure,0); lcd.setCursor(0,1); lcd.print("Max:"); lcd.setCursor(4,1); lcd.print(outputValueMax); lcd.setCursor(0,2); lcd.print("Alc:"); delay(10); lcd.setCursor(4,2); lcd.print(alcoholX); lcd.setCursor(0,3); lcd.print("Secs:"); lcd.setCursor(5,3); lcd.print(c); lcd.setCursor(11,3); delay(10); lcd.print("Mins:"); lcd.setCursor(16,3); lcd.print(mins,1); lcd.setCursor(11,1); lcd.print("A:"); delay(10); lcd.setCursor(11,2); lcd.print("T:"); lcd.setCursor(13,2); lcd.print(tempC); lcd.setCursor(18,2); lcd.print("\337C"); } void printTemperature() { Serial.println(" "); sensors.requestTemperatures(); Serial.print("Boiler Temp: "); boilerTemp =sensors.getTempCByIndex(1)-0.76; // Change the index value accordingly. Serial.println(boilerTemp); sensors.requestTemperatures(); Serial.print("Reflux Temp: "); refluxTemp =sensors.getTempCByIndex(2)-0.76; // Change the index value accordingly. Serial.println(refluxTemp); sensors.requestTemperatures(); Serial.print("Condensor Temp: "); condensorTemp =sensors.getTempCByIndex(0)-0.76; // Change the index value accordingly. Serial.println(condensorTemp); sensors.requestTemperatures(); Serial.print("Hydrometer Temp: "); hydroTemp =sensors.getTempCByIndex(3)-0.76; // Change the index value accordingly. Serial.println(hydroTemp); Serial.println(" "); tempC=boilerTemp; } void pressureZeroing() { x = outputValue; outputValueMin = 10000; outputValueMax = -10000; c = 0; totalAdjustedOutputValue =0; av=0; hrs=0; } void lcdTemperatures() { lcd.setCursor(0,0); lcd.print("Boiler Temp:"); lcd.setCursor(12,0); lcd.print(" "); lcd.setCursor(12,0); lcd.print(boilerTemp,2); lcd.setCursor(18,0); lcd.print("\337C"); lcd.setCursor(0,1); lcd.print("Reflux Temp:"); lcd.setCursor(12,1); lcd.print(refluxTemp,2); lcd.setCursor(18,1); lcd.print("\337C"); lcd.setCursor(0,2); lcd.print("Conden Temp:"); lcd.setCursor(12,2); lcd.print(condensorTemp,2); lcd.setCursor(18,2); lcd.print("\337C"); lcd.setCursor(0,3); lcd.print("Hydrom Temp:"); lcd.setCursor(12,3); lcd.print(hydroTemp,2); lcd.setCursor(18,3); lcd.print("\337C"); } void lcdStuff() { lcd.setCursor(0,0); lcd.print(" "); lcd.setCursor(0,1); lcd.print(" "); lcd.setCursor(0,2); lcd.print(" "); lcd.setCursor(0,3); lcd.print(" "); lcd.setCursor(0,0); lcd.print("P:"); delay(10); lcd.setCursor(2,0); lcd.print(pressure,0); lcd.setCursor(11,0); lcd.write(1); lcd.print("T:"); lcd.setCursor(14,0); lcd.print(deltaTempC); lcd.setCursor(0,1); lcd.print("Max:"); lcd.setCursor(4,1); lcd.print(outputValueMax); lcd.setCursor(0,2); lcd.print("Alc:"); delay(10); lcd.setCursor(4,2); lcd.print(alcoholX); lcd.setCursor(0,3); lcd.print("Secs:"); lcd.setCursor(5,3); c=millis()/1000; lcd.print(c); lcd.setCursor(11,3); delay(10); lcd.print("Mins:"); lcd.setCursor(16,3); mins=c/60; lcd.print(mins,1); lcd.setCursor(11,1); lcd.print("A:"); delay(10); lcd.setCursor(11,2); lcd.print("T:"); lcd.setCursor(13,2); lcd.print(tempC); lcd.setCursor(18,2); lcd.print("\337C"); if (ethanol>100) { lcd.setCursor(13,1); lcd.print("VOID"); totalAdjustedOutputValue =0; c=0; } else { lcd.setCursor(13,1); lcd.print(ethanol,0); lcd.setCursor(16,1); lcd.write(2); } } void foreshotsDump() { z=15; if ((pressure > 500)&&(y<z)&&(foreshotsDumpValue==0)) { digitalWrite(37, LOW); // SFX delay(500); digitalWrite(37, HIGH); digitalWrite(8, HIGH); // dump valve relay. while (y<(z+1)) { y++; delay(500); } foreshotsDumpValue++; lcd.clear(); } else { digitalWrite(8, LOW); } } void startAndEndDump() { z=15; if ((y<z)&&(startAndEndDumpValue==0)) { digitalWrite(8, HIGH); // dump valve relay. digitalWrite(37, LOW); delay(500); digitalWrite(37, HIGH); while (y<(z+1)) { lcd.setCursor(0,0); lcd.print(" DUMPING "); lcd.setCursor(0,1); lcd.print(" "); lcd.setCursor(0,2); lcd.print(" "); lcd.setCursor(0,3); lcd.print(" "); y++; delay(500); } startAndEndDumpValue++; y=5; delay(1000); digitalWrite(7, HIGH); // Neutralise hydomter pressure sensor by 3 way solenoid in tube. tone(A0,600,600); delay(5000); tone(A0,600,600); delay(1000); digitalWrite(7, LOW); lcd.clear(); } else { digitalWrite(8, LOW); } } void testRelays() { digitalWrite(8, HIGH); delay(2000); digitalWrite(8, LOW); digitalWrite(6, HIGH); delay(2000); digitalWrite(6, LOW); digitalWrite(7, HIGH); delay(2000); digitalWrite(7, LOW); digitalWrite(13, HIGH); delay(2000); digitalWrite(13, LOW); digitalWrite(9, HIGH); delay(2000); digitalWrite(9, LOW); } void printAddress(DeviceAddress deviceAddress) { for (uint8_t i = 0; i < 8; i++) { // zero pad the address if necessary if (deviceAddress[i] < 16) Serial.print("0"); Serial.print(deviceAddress[i], HEX); } } void sendData() { // We're going to turn testAAAA and testBBBB into shorter numbers to transmit: // assume the number is less than 1,000 and we want to preserve the first two decimal places testAAAA = nothing + tempZ*100; stringLengthAA = testAAAA.length(); testAAAA.remove((stringLengthAA-3),3); // Remove decimal place etc. // Serial.print("testAAAA: ");Serial.println(testAAAA); Wire.write(dataPrecursor); // Must send this junk data precursor first! Wire.write(numberId); // Serial.print("numberId is: ");Serial.println(numberId); Wire.write(stringLengthAA-3); n=stringLengthAA-4; while (n>-1) // Send the data back to front. { digitCharAAAA[n-1] = testAAAA.charAt(n); n--; digitAAAA = (digitCharAAAA[n]+nothing).toInt(); // Serial.print("Digit to send: "); Serial.println(digitAAAA); delay(20); Wire.write(int (digitAAAA)); // Values must not be greater than 255 (1 byte)? } }

end.