 // MAIN LOOP
 //========================================
 
-void loop()
+inline void stackCheck()
 {
     // Force restart if SPAM/heap/stack likely corrupt.
-    OTV0P2BASE::MemoryChecks::forceResetIfStackOverflow();
     // Complain and keep complaining when getting near stack overflow.
     // TODO: make DEBUG-only when confident all configs OK.
     const int16_t minsp = OTV0P2BASE::MemoryChecks::getMinSPSpaceBelowStackToEnd();
-    if(minsp < 64) { OTV0P2BASE::serialPrintlnAndFlush(F("!SH")); }
+    const uint8_t location = OTV0P2BASE::MemoryChecks::getLocation();
+    OTV0P2BASE::serialPrintAndFlush(F("minsp: "));
+    OTV0P2BASE::serialPrintAndFlush(minsp, HEX);
+    OTV0P2BASE::serialPrintAndFlush(F(" loc:"));
+    OTV0P2BASE::serialPrintAndFlush(location);
+    OTV0P2BASE::serialPrintlnAndFlush();
+
+    OTV0P2BASE::MemoryChecks::forceResetIfStackOverflow();
+
+    OTV0P2BASE::MemoryChecks::resetMinSP();
+}
+
+void loop()
+{
+    stackCheck();
 
         // Sensor readings are taken late in each minute (where they are taken)
     // and if possible noise and heat and light should be minimised in this part of each minute to improve readings.


// UDP Configs - Edit SIM900_UDP_ADDR for relevant server. NOTE: The server IP address should never be committed to GitHub.
// IP adress in seperate header to avoid accidentally committing.
//static const char SIM900_UDP_ADDR[16] PROGMEM = ""; // Of form "1.2.3.4".
static const char SIM900_UDP_PORT[5] PROGMEM = "9999";             // Standard port for OpenTRV servers
const OTSIM900Link::OTSIM900LinkConfig_t SIM900Config(
                                                false,


    // Handling the UI may have taken a little while, so process I/O a little.
    pollIO(); // Deal with any pending I/O.
    messageQueue.handle(true, PrimaryRadio); // Deal with any pending I/O.

    // DO SCHEDULING
