diff --git a/sam/src/SckAux.cpp b/sam/src/SckAux.cpp index 718bf61..c350b1b 100644 --- a/sam/src/SckAux.cpp +++ b/sam/src/SckAux.cpp @@ -1577,7 +1577,13 @@ bool Atlas::getBusyState() if (millis() - lastUpdate < 2) return true; switch (state) { - case REST: { + case SLEEP: { + + if (millis() - lastCommandSent >= shortWait) { + if (sendCommand((char*)"r")) state = REST; + } + + } case REST: { // ORP doesn't need temp compensation so we jump directly to ask reading if (ORP) { @@ -1668,7 +1674,9 @@ void Atlas::goToSleep() auxWire.beginTransmission(deviceAddress); auxWire.write("Sleep"); auxWire.endTransmission(); + state = SLEEP; } + bool Atlas::sendCommand(char* command) { @@ -1688,7 +1696,7 @@ bool Atlas::sendCommand(char* command) return true; } - delay(300); + delay(shortWait); } return false; } diff --git a/sam/src/SckAux.h b/sam/src/SckAux.h index 49db7a8..cb7147b 100644 --- a/sam/src/SckAux.h +++ b/sam/src/SckAux.h @@ -360,6 +360,7 @@ class Atlas uint32_t lastUpdate = 0; enum State { REST, + SLEEP, TEMP_COMP_SENT, ASKED_READING, };