Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*Thermostat with Real Time Clock Module and web support using second Arduino with ethernet shield.
- This sketch takes temp readings from three temp sensors and a door sensor and decides when to turn the heat on or off.
- steve.a.mccluskey@gmail.com
- Revisions:
- V2.2: Web support using second arduino with ethernet shield. Master sends single char commands over serial and thermostat responds accordingly.
- V2.3: Added door and heater state to web page.
- V2.4: Added EEPROM functionality to save settings to resume on startup.
- V2.5: Added code to handle if one of the sensors is unplugged on the web page, 02/18/14.
- V2.6: Rewrote button polling, bottom line display and ReadTimeDate() with switch/cases; consolidated door logic, rewrote average functions. 02/19/14.
- V2.7: Added functionality to display negative temps down to -40. 02/20/14.
- V2.8: Removed averageC(), removed unneccesary lcd.setCursor()'s, fixed average() to correctly return negative temps, changed tempAvgC calculation,
- sensorInterval variable added, C/F mode saved to EEPROM, tempHold limited to 12F minimum, getTemp() analog reading to tempC now uses floating point math and rounding. 03/02/14.
- Changed average() to use floating point math as well. 03/03/14.
- V2.9: Changed how often ReadTimeDate() is called. 03/05/14.
- V3.0: Added daylight savings time option menu and functionality. 02/23/15.
- V3.1: Added doorState variable and only reads door once per loop instead of several times. 02/25/15.
- V3.2: Changed ReadTimeDate() to only initialize one string instead of three. Added heaterDelay variable. 02/27/15.
- V4.0: Added One-Wire Temp sensor support for outdoor temps and getOneWireTemp(). Changed temp variables to temp1, temp2, temp3 from tempNear/Far/Out.
- Fixed closing parenthesis typo in getTemp(). Changed const uint8_t's to #define in pin declarations. Limited data[] to two slots in getOneWireTemp(). 03/02/14.
- Version 4.0 which uses analog TMP36 temp sensors can be found here: http://pastebin.com/YxKFUr2y
- V5.0: Rewrote entire sketch to use I2C temp sensors and I2C clock module. 03/04/14.
- V5.1: TempHold is now changeable on M8 (temp Out) screen. Added RTC_Interval and changed sensorInterval. Added lastClockCheck2 variable. 03/09/14.
- Pin layout as follows:
- 0 : Hardware serial RX.
- 1 : Hardware serial TX.
- 2 :
- 3 ~: Green LED.
- 4 :
- 5 ~: Yellow LED.
- 6 ~: Red LED.
- 7 : Door sensor.
- 8 : Heater relay.
- 9 ~:
- 10~: OneWire bus.
- 11~:
- 12 :
- 13 :
- A0 :
- A1 :
- A2 :
- A3 :
- A4 : I2C SDA.
- A5 : I2C CLK.
- Sketch outline:
- Libraries.
- Pin Declarations.
- Global Variables.
- setup().
- loop() {
- Static variables.
- Poll door.
- Poll buttons.
- Poll sensors.
- Print avg/hold to first line.
- Print menu to second line.
- Door closed: switch/case for second line.
- Door open: door open.
- Heater on/off logic.
- }
- cToF().
- getOneWireTemp().
- heaterOn().
- heaterOff().
- clearLine().
- average().
- serialEvent().
- */
- #include <Wire.h>
- #include "RTClib.h"
- #include <RTC_DS1307.h>
- #include "Adafruit_MCP9808.h"
- #include <Adafruit_MCP23017.h>
- #include <Adafruit_RGBLCDShield.h>
- #include <EEPROM.h>
- #include <OneWire.h>
- #include <SPI.h>
- #define RTC_Interval 150 //delay between RTC updates.
- #define sensorInterval 1000 //delay between sensor readings.
- #define heaterDelay 120000 //heater on/off delay.
- //pin declarations:
- #define greenLed 3
- #define yellowLed 5
- #define redLed 6
- #define door 7
- #define relay 8
- #define oneWireBus 10
- OneWire oneWire(oneWireBus);
- byte addr[8]; //array to store OneWire device's address.
- Adafruit_RGBLCDShield lcd = Adafruit_RGBLCDShield();
- RTC_DS1307 rtc;
- Adafruit_MCP9808 tempSensor1 = Adafruit_MCP9808();
- Adafruit_MCP9808 tempSensor2 = Adafruit_MCP9808();
- Adafruit_MCP9808 tempSensor3 = Adafruit_MCP9808();
- //global variables:
- boolean celsius = EEPROM.read(5);
- boolean doorLineCleared = false;
- boolean daylightSavings = EEPROM.read(6);
- uint8_t tempHold = EEPROM.read(0); // read saved tempHold value from EEPROM.
- int8_t tempReduction = EEPROM.read(1);
- uint8_t menu = EEPROM.read(4);
- int8_t temp1, temp2, temp3, tempOneWire, tempAvg; // variables to store temps.
- unsigned long heaterOnTime = 0, heaterOffTime = 0, currentTime = 0, lastReadingTime = 0, lastClockCheck = 0, lastClockCheck2 = 0;
- uint8_t heaterState = 0, doorState = 0;
- DateTime now;
- uint8_t hour;
- uint8_t eveningHour = EEPROM.read(3);
- uint8_t morningHour = EEPROM.read(2);
- void setup() {
- pinMode(redLed, OUTPUT);
- pinMode(greenLed, OUTPUT);
- pinMode(yellowLed, OUTPUT);
- pinMode(door, INPUT_PULLUP); //door pin is pulled to ground while door is closed.
- pinMode(relay, OUTPUT);
- Serial.begin(19200);
- Wire.begin();
- lcd.begin(16, 2);
- lcd.setCursor(0, 0);
- lcd.print(F("RTC Thermostat"));
- lcd.setCursor(0, 1);
- lcd.print(F("V 5.1"));
- delay(1000);
- tempSensor1.begin(0x18); //I2C address.
- tempSensor2.begin(0x19);
- tempSensor3.begin(0x1A);
- oneWire.search(addr); //get connected OneWire device address.
- rtc.begin();
- //rtc.adjust(DateTime(__DATE__, __TIME__)); //set RTC to time of compile, will revert to that time every time arduino is reset. run once and then comment out and reload.
- lcd.clear();
- } //end setup().
- void loop() {
- uint8_t buttons = lcd.readButtons(); //MUST be in main loop. will not work if global.
- if (digitalRead(door) == HIGH) { //only read once per loop.
- doorState = 1;
- } //end if.
- else {
- doorState = 0;
- } //end else.
- currentTime = millis();
- int8_t tempAvgC, temp1C, temp2C, temp3C, tempOneWireC;
- float convF = (5.0 * (tempHold - 32)) / 9.0;
- int8_t tempHoldC = round(convF);
- int8_t tempReductionC = tempReduction / 4;
- if (buttons) { //poll the buttons.
- if (buttons & BUTTON_SELECT) {
- celsius = !celsius;
- EEPROM.write(5, celsius); //only write to EEPROM when something is changed to reduce write cycles.
- } //end if.
- else if (buttons & BUTTON_UP) {
- switch (menu) { //update variables depending on which menu is selected.
- case 1:
- tempHold += 2;
- if (tempHold > 80) {
- tempHold = 80;
- } //end if.
- EEPROM.write(0, tempHold);
- break; //end case 1.
- case 2:
- tempReduction += 2;
- if (tempReduction > 12) {
- tempReduction = 12;
- } //end if.
- EEPROM.write(1, tempReduction);
- break; //end case 2.
- case 3:
- eveningHour ++;
- if (eveningHour > 24) {
- eveningHour = 24;
- } //end if.
- EEPROM.write(3, eveningHour);
- break; //end case 3.
- case 4:
- morningHour ++;
- if (morningHour > 11) {
- morningHour = 11;
- } //end if.
- EEPROM.write(2, morningHour);
- break; //end case 4.
- case 5:
- break; //end case 5.
- case 6:
- break; //end case 6.
- case 7:
- daylightSavings = !daylightSavings;
- EEPROM.write(6, daylightSavings);
- break; //end case 7.
- case 8:
- tempHold += 2;
- if (tempHold > 80) {
- tempHold = 80;
- } //end if.
- EEPROM.write(0, tempHold);
- break; //end case 8.
- default:
- break;
- } //end switch.
- } //end if button_up.
- else if (buttons & BUTTON_DOWN) {
- switch (menu) {
- case 1:
- tempHold -= 2;
- if (tempHold < 12) {
- tempHold = 12;
- } //end if.
- EEPROM.write(0, tempHold);
- break; //end case 1.
- case 2:
- tempReduction -= 2;
- if (tempReduction <= 0) {
- tempReduction = 0;
- } //end if.
- EEPROM.write(1, tempReduction);
- break; //end case 2.
- case 3:
- eveningHour --;
- if (eveningHour < 16) {
- eveningHour = 16;
- } //end if.
- EEPROM.write(3, eveningHour);
- break; //end case 3.
- case 4:
- morningHour --;
- if (morningHour < 3) {
- morningHour = 3;
- } //end if.
- EEPROM.write(2, morningHour);
- break; //end case 4.
- case 5:
- break; //end case 5.
- case 6:
- break; //end case 6.
- case 7:
- daylightSavings = !daylightSavings;
- EEPROM.write(6, daylightSavings);
- break; //end case 7.
- case 8:
- tempHold -= 2;
- if (tempHold < 12) {
- tempHold = 12;
- } //end if.
- EEPROM.write(0, tempHold);
- break;
- default:
- break;
- } //end switch
- } //end if button_down.
- else if (buttons & BUTTON_RIGHT) {
- menu ++;
- clearLine(); //clears 2nd line only when menu number is changed.
- if (menu > 8) {
- menu = 1;
- } //end if.
- EEPROM.write(4, menu);
- } //end if.
- else if (buttons & BUTTON_LEFT) {
- menu --;
- clearLine();
- if (menu < 1) {
- menu = 8;
- } //end if.
- EEPROM.write(4, menu);
- } //end if.
- } // end if buttons.
- if (currentTime - lastClockCheck2 > RTC_Interval) { //get hour of day from RTC.
- now = rtc.now();
- hour = now.hour();
- if (daylightSavings) {
- hour += 1;
- } //end if.
- lastClockCheck2 = currentTime;
- } //end if.
- if (currentTime - lastReadingTime > sensorInterval) { //only poll sensors every interval
- if (!celsius) {
- temp1 = cToF(tempSensor1.readTempC()); //poll the sensors.
- temp2 = cToF(tempSensor2.readTempC());
- temp3 = cToF(tempSensor3.readTempC());
- tempAvg = average(temp1, temp2, temp3);
- tempOneWire = getOneWireTemp();
- } //end if.
- else {
- temp1C = tempSensor1.readTempC();
- temp2C = tempSensor2.readTempC();
- temp3C = tempSensor3.readTempC();
- tempAvgC = average(temp1C, temp2C, temp3C);
- tempOneWireC = getOneWireTemp();
- } //end else.
- lastReadingTime = currentTime;
- } //end if.
- //print avg to screen:
- lcd.setCursor(0, 0);
- lcd.print(F("Avg:"));
- if (!celsius) {
- if (tempAvg >= -40 && tempAvg < 0) { //displays negative temps.
- lcd.print(tempAvg);
- lcd.print(F("F"));
- } //end if.
- else if (tempAvg >= 0) { //displays positive temps and clears last digit.
- lcd.print(tempAvg);
- lcd.print(F("F "));
- } //end else if.
- else {
- lcd.print(F("--F ")); //displays "--" if all 3 sensors are unplugged.
- } //end else.
- } //end if !celsius.
- else {
- if (tempAvgC >= -40 && tempAvgC < 0) {
- lcd.print(tempAvgC);
- lcd.print(F("C"));
- } //end if.
- else if (tempAvgC >= 0) {
- lcd.print(tempAvgC);
- lcd.print(F("C "));
- } //end else if.
- else {
- lcd.print(F("--C "));
- } //end else.
- } //end else.
- //print hold temp to screen:
- lcd.setCursor(8, 0);
- lcd.print(F("Hold:"));
- lcd.setCursor(13, 0);
- if (hour < morningHour || hour >= eveningHour) { //displays night temp hold at night.
- if (!celsius) {
- lcd.print(tempHold - tempReduction);
- lcd.print(F("*")); //star indicates night time temp reduction.
- } //end if.
- else {
- lcd.print(tempHoldC - tempReductionC);
- lcd.print(F("*"));
- } //end else.
- } //end if.
- else if (hour >= morningHour && hour < eveningHour) { //displays regular temp hold during day.
- if (!celsius) {
- lcd.print(tempHold);
- lcd.print(F("F"));
- } //end if.
- else {
- lcd.print(tempHoldC);
- lcd.print(F("C"));
- } //end else.
- } //end else if.
- lcd.setCursor(0, 1);
- lcd.print(F("M")); //displays menu number.
- lcd.print(menu);
- //bottom line display:
- if (doorState == 0) {
- analogWrite(redLed, 0);
- digitalWrite(greenLed, HIGH); //green led indicates system normal.
- if (!doorLineCleared) { //only clears line once when door is shut.
- clearLine();
- doorLineCleared = true;
- } //end if.
- switch (menu) {
- case 1: //displays sensors to screen and allows changing of temp hold.
- lcd.setCursor(2, 1);
- if (!celsius) { //sensor one:
- if (temp1 < -40) { //displays "--" if tempNear returns null and clears leading minus sign.
- lcd.print(F(" --"));
- } //end if.
- else if (temp1 >= -40 && temp1 < 0) { //negative temps.
- lcd.print(temp1);
- } //end else if.
- else {
- lcd.print(F(" ")); //positive temps and clears minus sign.
- lcd.print(temp1);
- } //end else.
- lcd.print(F("F "));
- } //end if.
- else {
- if (temp1C < -40) {
- lcd.print(F(" --"));
- } //end if.
- else if (temp1C >= 40 && temp1C < 0) {
- lcd.print(temp1C);
- } //end else if.
- else {
- lcd.print(F(" "));
- lcd.print(temp1C);
- } // end else.
- lcd.print(F("C "));
- } //end else.
- lcd.setCursor(7, 1);
- if (!celsius) { //sensor 2:
- if (temp2 < -40) {
- lcd.print(F(" --"));
- } //end if.
- else if (temp2 >= -40 && temp2 < 0) {
- lcd.print(temp2);
- } //end else if.
- else {
- lcd.print(F(" "));
- lcd.print(temp2);
- } //end else.
- lcd.print(F("F "));
- } //end if.
- else {
- if (temp2C < -40) {
- lcd.print(F(" --"));
- } //end if.
- else if (temp2C >= 40 && temp2C < 0) {
- lcd.print(temp2C);
- } //end else if.
- else {
- lcd.print(F(" "));
- lcd.print(temp2C);
- } // end else.
- lcd.print(F("C "));
- } //end else.
- lcd.setCursor(12, 1);
- if (!celsius) { //sensor 3:
- if (temp3 < -40) {
- lcd.print(F(" --"));
- } //end if.
- else if (temp3 >= -40 && temp3 < 0) {
- lcd.print(temp3);
- } //end else if.
- else {
- lcd.print(F(" "));
- lcd.print(temp3);
- } //end else.
- lcd.print(F("F "));
- } //end if.
- else {
- if (temp3C < -40) {
- lcd.print(F(" --"));
- } //end if.
- else if (temp3C >= 40 && temp3C < 0) {
- lcd.print(temp3C);
- } //end else if.
- else {
- lcd.print(F(" "));
- lcd.print(temp3C);
- } // end else.
- lcd.print(F("C "));
- } //end else.
- break; //end menu 1.
- case 2: //displays temp drop amount.
- lcd.setCursor(3, 1);
- lcd.print(F("Drop Temp:"));
- if (!celsius) {
- if (tempReduction < 10) {
- lcd.print(F(" "));
- } //end if.
- lcd.print(tempReduction);
- lcd.print(F("F"));
- } //end if.
- else {
- if (tempReductionC < 10) {
- lcd.print(F(" "));
- } //end if.
- lcd.print(tempReductionC);
- lcd.print(F("C"));
- } //end else.
- break; //end menu 2.
- case 3: //displays PM time to drop temp:
- lcd.setCursor(3, 1);
- lcd.print(F("Heat Dn: "));
- if (eveningHour < 22) {
- lcd.print(F(" "));
- } //end if.
- lcd.print(eveningHour - 12);
- lcd.print(F("pm"));
- break; //end menu 3.
- case 4: //displays AM time to raise temp:
- lcd.setCursor(3, 1);
- lcd.print(F("Heat Up: "));
- if (morningHour < 10) {
- lcd.print(F(" "));
- } //end if.
- lcd.print(morningHour);
- lcd.print(F("am"));
- break; //end menu 4.
- case 5: //display time to 2nd row:
- lcd.setCursor(4, 1);
- lcd.print(F("Tm: "));
- if (currentTime - lastClockCheck > RTC_Interval) {
- now = rtc.now();
- if (hour < 10) {
- lcd.print(F(" "));
- } //end if.
- lcd.print(now.hour());
- lcd.print(F(":"));
- if (now.minute() < 10) {
- lcd.print(F("0"));
- } //end if.
- lcd.print(now.minute());
- lcd.print(F(":"));
- if (now.second() < 10) {
- lcd.print(F("0"));
- } //end if.
- lcd.print(now.second());
- lastClockCheck = currentTime;
- } //end if.
- break; //end menu 5.
- case 6: //display date to 2nd row:
- lcd.setCursor(4, 1);
- lcd.print(F("Dt: "));
- if (currentTime - lastClockCheck > RTC_Interval) {
- now = rtc.now();
- if (now.month() < 10) {
- lcd.print(F(" "));
- } //end if.
- lcd.print(now.month());
- lcd.print(F("/"));
- if (now.day() < 10) {
- lcd.print(F("0"));
- } //end if.
- lcd.print(now.day());
- lcd.print(F("/"));
- lcd.print(now.year() - 2000);
- lastClockCheck = currentTime;
- } //end if.
- break; //end menu 6.
- case 7: //daylight savings time enable/disable:
- lcd.setCursor(4, 1);
- lcd.print(F("DST:"));
- if (daylightSavings) {
- lcd.print(F("Active "));
- } //end if.
- else {
- lcd.print(F("Inactive"));
- } //end else.
- break; //end menu 7.
- case 8: //prints outside temp to screen.
- lcd.setCursor(4, 1);
- lcd.print(F("Out: "));
- if (!celsius) {
- if (tempOneWire > -51) {
- lcd.print(tempOneWire);
- } //end if.
- else {
- lcd.print("--");
- } //end else.
- lcd.print(F("F "));
- } //end if celsius.
- else {
- if (tempOneWireC > -51) {
- lcd.print(tempOneWireC);
- } //end if.
- else {
- lcd.print("--");
- } //end else.
- lcd.print(F("C "));
- } // else.
- break; //end case 8.
- } //end switch menu.
- } //end if door closed.
- else {
- doorLineCleared = false;
- lcd.setCursor(2, 1);
- lcd.print(F(" Door open! "));
- digitalWrite(greenLed, LOW);
- digitalWrite(yellowLed, LOW);
- digitalWrite(relay, LOW);
- heaterState = 0;
- analogWrite(redLed, 180);
- heaterOffTime = currentTime;
- } //end else if.
- //decide when to turn heater on or off:
- if (hour >= morningHour && hour < eveningHour) { //day time
- if (((!celsius && tempAvg > -41 && tempAvg < tempHold) ||
- (celsius && tempAvgC > -41 && tempAvgC < tempHoldC)) && doorState == 0) {
- heaterOn();
- } //end if.
- else {
- heaterOff();
- } //end else.
- } //end if day time.
- else if (hour < morningHour || hour >= eveningHour) { //night time
- if (((!celsius && tempAvg > -41 && tempAvg < (tempHold - tempReduction)) ||
- (celsius && tempAvgC > -41 && tempAvgC < (tempHoldC - tempReductionC))) && doorState == 0) {
- heaterOn();
- } //end if.
- else {
- heaterOff();
- } //end else.
- } //end if night time.
- } //end loop().
- int8_t cToF(float c) { //convert float C to int F.
- return round((1.8 * c) + 32.0);
- } //end cToF().
- int8_t getOneWireTemp() { //get OneWire temp.
- byte data[2]; //array to store data retrieved from sensor.
- oneWire.reset();
- oneWire.select(addr);
- oneWire.write(0x44, 1); //start conversion.
- oneWire.reset();
- oneWire.select(addr);
- oneWire.write(0xBE); //read scratchpad.
- for (byte i = 0; i < 2; i ++) {
- data[i] = oneWire.read(); //collect data.
- } //end for.
- int16_t raw = (data[1] << 8) | data[0]; //convert raw data to C.
- if (celsius) {
- return round((float)raw / 16.0);
- } //end if.
- else {
- return round(((float)raw / 16.0) * 1.8 + 32.0);
- } //end else.
- } //end getOneWireTemp().
- void heaterOn() {
- if (currentTime - heaterOffTime > heaterDelay) { //check to see if heater has been off for at least 2 min.
- digitalWrite(relay, HIGH);
- analogWrite(yellowLed, 180);
- heaterOnTime = currentTime;
- heaterState = 1;
- } //end if.
- } //end heaterOn().
- void heaterOff() {
- if (currentTime - heaterOnTime > heaterDelay) { //check to see if heater has been on for at least 2 min.
- digitalWrite(relay, LOW);
- digitalWrite(yellowLed, LOW);
- heaterOffTime = currentTime;
- heaterState = 0;
- } //end if.
- } //end heaterOff().
- void clearLine() { //clears 2nd line past M#.
- lcd.setCursor(2, 1);
- lcd.print(F(" "));
- } //end clearLine().
- int8_t average(int8_t temp_1, int8_t temp_2, int8_t temp_3) { //averages 3 temps and knows how depending on which sensors are plugged in.
- uint8_t count = 0;
- float avg = 0.0;
- if (temp_1 > -41) { //sensor connected.
- count ++;
- avg += temp_1;
- } //end if.
- if (temp_2 > -41) {
- count ++;
- avg += temp_2;
- } //end if.
- if (temp_3 > -41) {
- count ++;
- avg += temp_3;
- } //end if.
- if (count != 0) {
- return round(avg / count);
- } //end if.
- else {
- return -41; //all three sensors unplugged.
- } //end else.
- } //end average().
- void serialEvent() { //called any time serial data is available.
- char c = Serial.read();
- switch (c) {
- case '*': //all values requested. sends string of data to be served by other arduino. IE " 64h63a17j9e7m8t0d1f61x62y65z58w* "
- Serial.print(tempHold);
- Serial.print(F("h")); //indicates end of tempHold.
- if (tempAvg > -41) {
- Serial.print(tempAvg);
- } //end if.
- else {
- Serial.print(F("--"));
- } //end else.
- Serial.print(F("a"));
- Serial.print(hour);
- Serial.print(F("j"));
- Serial.print(eveningHour);
- Serial.print(F("e"));
- Serial.print(morningHour);
- Serial.print(F("m"));
- Serial.print(tempReduction);
- Serial.print(F("t"));
- Serial.print(doorState);
- Serial.print(F("d"));
- Serial.print(heaterState);
- Serial.print(F("f"));
- if (temp1 > -41) {
- Serial.print(temp1);
- } //end if.
- else {
- Serial.print(F("--"));
- } //end else.
- Serial.print(F("x"));
- if (temp2 > -41) {
- Serial.print(temp2);
- } //end if.
- else {
- Serial.print(F("--"));
- } //end else.
- Serial.print(F("y"));
- if (temp3 > -41) {
- Serial.print(temp3);
- } //end if.
- else {
- Serial.print(F("--"));
- } //end else.
- Serial.print(F("z"));
- if (tempOneWire > -51) {
- Serial.print(tempOneWire);
- }
- else {
- Serial.print(F("--"));
- }
- Serial.print(F("w"));
- Serial.println(F("*")); //end of data character.
- break; //end case '*'.
- case 'h': //increase hold temp.
- tempHold += 2;
- if (tempHold > 80) {
- tempHold = 80;
- } //end if.
- EEPROM.write(0, tempHold);
- break; //end case 'h'.
- case 'n': //decrease hold temp.
- tempHold -= 2;
- if (tempHold < 12) {
- tempHold = 12;
- } //end if.
- EEPROM.write(0, tempHold);
- break; //end case 'n'.
- case 'e': //heat off later.
- eveningHour ++;
- if (eveningHour > 24) {
- eveningHour = 24;
- } //end if.
- EEPROM.write(3, eveningHour);
- break; //end case 'e'.
- case 'd': //heat off earlier.
- eveningHour --;
- if (eveningHour < 16) {
- eveningHour = 16;
- } //end if.
- EEPROM.write(3, eveningHour);
- break; //end case 'd'.
- case 'm': //heat on later.
- morningHour ++;
- if (morningHour > 11) {
- morningHour = 11;
- } //end if.
- EEPROM.write(2, morningHour);
- break; //end case 'm'.
- case 'j': //heat on earlier.
- morningHour --;
- if (morningHour < 3) {
- morningHour = 3;
- } //end if.
- EEPROM.write(2, morningHour);
- break; //end case 'j'.
- case 't': //reduce temp more.
- tempReduction += 2;
- if (tempReduction > 12) {
- tempReduction = 12;
- } //end if.
- EEPROM.write(1, tempReduction);
- break; //end case 't'.
- case 'g': //reduce temp less.
- tempReduction -= 2;
- if (tempReduction < 0) {
- tempReduction = 0;
- } //end if.
- EEPROM.write(1, tempReduction);
- break; //end case 'g'.
- } //end switch.
- } //end serialEvent().
Add Comment
Please, Sign In to add comment