temperatuur instellen met decimalen

Voor wat betreft het slijten van de EEPROM. Dat is enkel het schrijven toch? Lezen kan oneindig vaak?

Of concreet, als ik mijn code voor de relays als volgt opstel, dan lees ik alleen de EEPROM, tenzij ik in mijn temperatuursettingpagina een nieuwe temperatuur instel/save. De huidige temperatuur wordt constant vergeleken met de temperatuur in EEPROM en indien lager dan de temperatuur in EEPROM, schakelt mijn relay en gaat de verwarming aan. Althans, dat is mijn bedoeling :slight_smile: Als het op deze manier geen nadelige effecten voor de levensduur van EEPROM heeft, kan het op deze manier toch? Klopt deze aanname?

//==Relays
#define IN A1 //Relay heater
#define IN A2 //Relay pH

//==Structs
struct config_t
{
  float tempSet;
  float pHSet;
};

struct config_t configuration;


//==Temp
float tempC = 0;
float tempNew = 18;
float tempUpg = 0.1;
float tempSet;

//==pH
float pHNew = 6.8;
float pHUpg = 0.1;
float pHSet;
float pHValue;


void setup() {
  // put your setup code here, to run once:
  myGLCD.InitLCD();
  myGLCD.clrScr();
  myTouch.InitTouch();
  myTouch.setPrecision(PREC_MEDIUM);

  sd.begin(); //init SD card

  sensors.begin();//init temp. sensor

  rtc.begin();// Initialize the rtc object

  //== Set time, run once, then deactivate again
  //rtc.setDOW(SATURDAY);     // Set Day-of-Week to SUNDAY
  //rtc.setTime(10, 36, 40);     // Set the time to 12:00:00 (24hr format)
  //rtc.setDate(14, 4, 2018);   // Set the date to January 1st, 2014

  tempNew = EEPROM.get(0, configuration.tempSet);
  pHNew = EEPROM.get(5, configuration.pHSet);

  pinMode (A1, OUTPUT); //set pin A1 as output signal for relay heater
  pinMode (A2, OUTPUT); //set pin A2 as output signal for relay pH (magneetventiel)
  digitalWrite (A1, LOW); //initially set relay heater off
  digitalWrite (A2, LOW); //initially set relay pH off

  drawHomeScreen();  // Draws the Home Screen
  currentPage = '0'; //sets current page to 0/homescreen
}

void relayTemp()
{
  if (tempC < EEPROM.get(0, configuration.tempSet))
  {
    digitalWrite (A1, HIGH);
  }
  else
  {
    digitalWrite (A1, LOW);
  }
}

void relaypH()
{
  if (pHValue > EEPROM.get(5, configuration.pHSet))
  {
    digitalWrite (A2, HIGH);
  }
  else
  {
    digitalWrite (A2, LOW);
  }
}

void loop()
{
  relayTemp();
  relaypH();

  //Home Screen
  currentMillis = millis(); //get the current "time" (actually the number of milliseconds since the program 
  started)

  if (currentMillis - pupdateMillis >= updateperiod)
  {
    pupdateMillis += updateperiod;
    if (currentPage == '0')
    {
      callTime();
      callTemp();
      callpH();
    }
    if (currentPage == '2')
    {
      callTemp();
    }
    if (currentPage == '3')
    {
      callpH();
    }
  }

// TemperatureSetting / Temp.config Screen
  if (currentPage == '2')
  {
    myGLCD.setColor(255, 255, 255);
    myGLCD.setBackColor(0, 0, 0);
    myGLCD.setFont(SmallFont);
    myGLCD.printNumF(EEPROM.get(0, configuration.tempSet), 1, 160, 56);
    myGLCD.setFont(BigFont);
    myGLCD.printNumF(tempNew, 1, 160, 135);

    if (myTouch.dataAvailable())
    {
      myTouch.read();
      x = myTouch.getX();
      y = myTouch.getY();

      // ==If we press the tempUp Button 10, 115, 90, 148
      if ((x >= 10) && (x <= 90) && (y >= 115) && (y <= 148))
      {
        tempNew < 28 ? tempNew = tempNew + tempUpg : tempNew = 18;
        delay (200);
      }

      // ==If we press the tempDown Button
      if ((x >= 10) && (x <= 90) && (y >= 156) && (y <= 189))
      {
        tempNew > 18 ? tempNew = tempNew - tempUpg : tempNew = 28;
        delay (200);
      }

      if (tempNew >= 20 && tempNew <= 25)
      {
        myGLCD.setBackColor(0, 0, 0);
        myGLCD.setColor(255, 255, 255);
        myGLCD.setFont(Various_Symbols_32x32);
        myGLCD.print("T", 235, 120);
      }
      if (tempNew < 20 || tempNew > 25)
      {
        myGLCD.setColor(255, 255, 255);
        myGLCD.setFont(Various_Symbols_32x32);
        myGLCD.setBackColor(0, 0, 0);
        myGLCD.print("O", 235, 120);
      }


      // ==If we press the saveTemp Button
      if ((x >= 170) && (x <= 210) && (y >= 190) && (y <= 230))
      {
        configuration.tempSet = tempNew;
        EEPROM.put(0, configuration.tempSet);
        drawFrame(170, 190, 210, 230);
      }

      // ==If we press the Main Button (270, 190, 310, 230)
      if ((x >= 270) && (x <= 310) && (y >= 190) && (y <= 230))
      {
        drawFrame(270, 190, 310, 230);
        currentPage = '0'; // Indicates we are at home screen
        myGLCD.clrScr();
        drawHomeScreen(); // Draws the Home Screen
      }
      // ==If we press the Back Button (210, 190, 260, 230)
      if ((x >= 220) && (x <= 260) && (y >= 190) && (y <= 230))
      {
        drawFrame(220, 190, 260, 230);
        currentPage = '1'; // Indicates we are at Setting screen
        myGLCD.clrScr();
        drawSettingScreen(); // Draws the Setting Screen
      }
    }
  }

...rest van code. Code is te lang om in zijn geheel te plaatsen en volgens mij niet nodig voor het stukje over relays. Zowel, dan hoor ik het graag.