A way to smoothen this sketch?

compiling:
Not quite finished with this sketch though, wanna add an automatic timer to automate the irrigation, will take some ram too...

I did not look at your code, but it sounds to me like you are trying to get the base to do everything. I have a similar kind of IoT system but using nrF24l01 radios. I made the Sensors "smart" so they react to controls from the base but mostly they handle the node's object (Swamp, pump, sensors etc) . You need to distribute the control code.

For instance, the swamp cooler runs on a Nano and it gets a time signal from the Base (Mega with RTC) every 30-minutes so it can keep a pretty reasonable idea of time with a seconds-pump. This is included in every Node.

  ///////////////////////////////////////////
  bool timePumpSecSM(uint32_t &secSM) {
    if (millis() - timePumpMillis > timePumpTIME) {
      ++secSM;
      secHMS(secSM);  // This locally breaks it into Hours, Mins and Secs
      timePumpMillis = millis();
      return true;
    } else {
      return false;
    }
  }

From there, the swamp-Nano has all of the code to run the pump, cycle the fan, purge the tray etc. It also changes set-temp between periods like, "Sleep," "Morning" etc. It gets the current temp sent to it by the base from an appropriate smart-temp sensor in each room. It (swamp Nano) decides what time of day it is and which temp to use.

Consequently the base-Mega as has a tiny amount of code as all of the heavy-lifting control is in each Node. This also makes it simple to add more Nodes as they are "smart" for their purpose, so the Base needs to know little more than their ID to send the the time occasionally and any other data they may need.

The base does not need to know or understand the data it is sending. Each Node send data about every minute or so depending on the need. The tank level only needs sending every hour, the temp every 30-seconds. All Nodes have a "SendStatus" command which is triggered by a command from the base if I want to know something between those times.

Adding more code to your base is going to hit a wall soon. :slight_smile:

I suspect you should bite the bullet and start again with an open ended design. But -- I have been wrong before. :slight_smile: